/**
 * easyui.datagrid插件
 * 依赖 ： panel, resizable, linkbutton, pagination
 */

//jquery.parser
(function($) {
    $.parser = {
        auto: true,
        onComplete: function(context) {},
        plugins: ["panel", "resizable", "linkbutton", "pagination", "datagrid"],
        parse: function(context) {
            var aa = [];
            for (var i = 0; i < $.parser.plugins.length; i++) {
                var name = $.parser.plugins[i];
                var r = $(".easyui-" + name, context);
                if (r.length) {
                    if (r[name]) {
                        r[name]();
                    } else {
                        aa.push({
                            name: name,
                            jq: r
                        });
                    }
                }
            }
           
            if (aa.length && window.easyloader) {
                var names = [];
                for (var i = 0; i < aa.length; i++) {
                    names.push(aa[i].name);
                }
                easyloader.load(names, function() {
                    for (var i = 0; i < aa.length; i++) {
                        var name = aa[i].name;
                        var jq = aa[i].jq;
                        jq[name]();
                    }
                    $.parser.onComplete.call($.parser, context);
                });
            } else {
                $.parser.onComplete.call($.parser, context);
            }
        },
        parseOptions: function(obj, attrs) {
            var tgtObj = $(obj);
            var result = {};
            var dataOptions = $.trim(tgtObj.attr("data-options"));
            if (dataOptions) {
                var first = dataOptions.substring(0, 1);
                var last = dataOptions.substring(dataOptions.length - 1, 1);
                if (first != "{") {
                    dataOptions = "{" + dataOptions;
                }
                if (last != "}") {
                    dataOptions = dataOptions + "}";
                }
                result = (new Function("return " + dataOptions))();
            }
            if (attrs) {
                var vals = {};
                for (var i = 0; i < attrs.length; i++) {
                    var attr = attrs[i];
                    if (typeof attr == "string") {
                        if (attr == "width" || attr == "height" || attr == "left" || attr == "top") {
                            vals[attr] = parseInt(obj.style[attr]) || undefined;
                        } else {
                            vals[attr] = tgtObj.attr(attr);
                        }
                    } else {
                        for (var key in attr) {
                            var dt = attr[key];
                            if (dt == "boolean") {
                                vals[key] = tgtObj.attr(key) ? (tgtObj.attr(key) == "true") : undefined;
                            } else {
                                if (dt == "number") {
                                    vals[key] = tgtObj.attr(key) == "0" ? 0 : parseFloat(tgtObj.attr(key)) || undefined;
                                }
                            }
                        }
                    }
                }
                $.extend(result, vals);
            }
            return result;
        }
    };
    $(function() {
        var d = $("<div style=\"position:absolute;top:-1000px;width:100px;height:100px;padding:5px\"></div>").appendTo("body");
        $._boxModel = parseInt(d.width()) == 100;
        d.remove();
        if (!window.easyloader && $.parser.auto) {
            $.parser.parse();
        }
        //alert('===parser.parseOptions');
    });
    $.fn._outerWidth = function(_e) {
        if (_e == undefined) {
            if (this[0] == window) {
                return this.width() || document.body.clientWidth;
            }
            return this.outerWidth() || 0;
        }
        return this.each(function() {
            if ($._boxModel) {
                $(this).width(_e - ($(this).outerWidth() - $(this).width()));
            } else {
                $(this).width(_e);
            }
        });
    };
    $.fn._outerHeight = function(_f) {
        if (_f == undefined) {
            if (this[0] == window) {
                return this.height() || document.body.clientHeight;
            }
            return this.outerHeight() || 0;
        }
        return this.each(function() {
            if ($._boxModel) {
                $(this).height(_f - ($(this).outerHeight() - $(this).height()));
            } else {
                $(this).height(_f);
            }
        });
    };
    $.fn._scrollLeft = function(_10) {
        if (_10 == undefined) {
            return this.scrollLeft();
        } else {
            return this.each(function() {
                $(this).scrollLeft(_10);
            });
        }
    };
    $.fn._propAttr = $.fn.prop || $.fn.attr;
    $.fn._fit = function(fit) {
        fit = fit == undefined ? true: fit;
        var t = this[0];
        var p = (t.tagName == "BODY" ? t: this.parent()[0]);
        var _11 = p.fcount || 0;
        if (fit) {
            if (!t.fitted) {
                t.fitted = true;
                p.fcount = _11 + 1;
                $(p).addClass("panel-noscroll");
                if (p.tagName == "BODY") {
                    $("html").addClass("panel-fit");
                }
            }
        } else {
            if (t.fitted) {
                t.fitted = false;
                p.fcount = _11 - 1;
                if (p.fcount == 0) {
                    $(p).removeClass("panel-noscroll");
                    if (p.tagName == "BODY") {
                        $("html").removeClass("panel-fit");
                    }
                }
            }
        }
        return {
            width: $(p).width(),
            height: $(p).height()
        };
    };
})(jQuery);

//jquery.panel
(function($) {
    $.fn._remove = function() {
        return this.each(function() {
            $(this).remove();
            try {
                this.outerHTML = "";
            } catch(err) {}
        });
    };
    function removeHtmlNode(node) {
        node._remove();
    };
    function _1d0(objs, params) {
        var opts = $.data(objs, "panel").options;
        var panelObj = $.data(objs, "panel").panel;
        var panelHeader = panelObj.children("div.panel-header");
        var panelBody = panelObj.children("div.panel-body");
        if (params) {
            if (params.width) {
                opts.width = params.width;
            }
            if (params.height) {
                opts.height = params.height;
            }
            if (params.left != null) {
                opts.left = params.left;
            }
            if (params.top != null) {
                opts.top = params.top;
            }
        }
        opts.fit ? $.extend(opts, panelObj._fit()) : panelObj._fit(false);
        panelObj.css({
            left: opts.left,
            top: opts.top
        });
        if (!isNaN(opts.width)) {
            panelObj._outerWidth(opts.width);
        } else {
            panelObj.width("auto");
        }
        panelHeader.add(panelBody)._outerWidth(panelObj.width());
        if (!isNaN(opts.height)) {
            panelObj._outerHeight(opts.height);
            panelBody._outerHeight(panelObj.height() - panelHeader._outerHeight());
        } else {
            panelBody.height("auto");
        }
        panelObj.css("height", "");
        opts.onResize.apply(objs, [opts.width, opts.height]);
        panelObj.find(">div.panel-body>div").triggerHandler("_resize");
    };
    function _1d6(objs, paramObj) {
        var opts = $.data(objs, "panel").options;
        var panelObj = $.data(objs, "panel").panel;
        if (paramObj) {
            if (paramObj.left != null) {
                opts.left = paramObj.left;
            }
            if (paramObj.top != null) {
                opts.top = paramObj.top;
            }
        }
        panelObj.css({
            left: opts.left,
            top: opts.top
        });
        opts.onMove.apply(objs, [opts.left, opts.top]);
    };
    function getPanel(objs) {
        $(objs).addClass("panel-body");
        var panelContainer = $("<div class='panel'></div>").insertBefore(objs);
        panelContainer[0].appendChild(objs);
        panelContainer.bind("_resize", function() {
            var opts = $.data(objs, "panel").options;
            if (opts.fit == true) {
                _1d0(objs);
            }
            return false;
        });
        return panelContainer;
    };
    function _1dd(objs) {
        var opts = $.data(objs, "panel").options;
        var panelObj = $.data(objs, "panel").panel;
        if (opts.tools && typeof opts.tools == "string") {
            panelObj.find(">div.panel-header>div.panel-tool .panel-tool-a").appendTo(opts.tools);
        }
        removeHtmlNode(panelObj.children("div.panel-header"));
        if (opts.title && !opts.noheader) {
            var _1e0 = $("<div class=\"panel-header\"><div class=\"panel-title\">" + opts.title + "</div></div>").prependTo(panelObj);
            if (opts.iconCls) {
                _1e0.find(".panel-title").addClass("panel-with-icon");
                $("<div class=\"panel-icon\"></div>").addClass(opts.iconCls).appendTo(_1e0);
            }
            var tool = $("<div class=\"panel-tool\"></div>").appendTo(_1e0);
            tool.bind("click", function(e) {
                e.stopPropagation();
            });
            if (opts.tools) {
                if (typeof opts.tools == "string") {
                    $(opts.tools).children().each(function() {
                        $(this).addClass($(this).attr("iconCls")).addClass("panel-tool-a").appendTo(tool);
                    });
                } else {
                    for (var i = 0; i < opts.tools.length; i++) {
                        var t = $("<a href=\"javascript:void(0)\"></a>").addClass(opts.tools[i].iconCls).appendTo(tool);
                        if (opts.tools[i].handler) {
                            t.bind("click", eval(opts.tools[i].handler));
                        }
                    }
                }
            }
            if (opts.collapsible) {
                $("<a class=\"panel-tool-collapse\" href=\"javascript:void(0)\"></a>").appendTo(tool).bind("click",
                function() {
                    if (opts.collapsed == true) {
                        expandPanel(objs, true);
                    } else {
                        _1f0(objs, true);
                    }
                    return false;
                });
            }
            if (opts.minimizable) {
                $("<a class=\"panel-tool-min\" href=\"javascript:void(0)\"></a>").appendTo(tool).bind("click",
                function() {
                    _201(objs);
                    return false;
                });
            }
            if (opts.maximizable) {
                $("<a class=\"panel-tool-max\" href=\"javascript:void(0)\"></a>").appendTo(tool).bind("click",
                function() {
                    if (opts.maximized == true) {
                        _204(objs);
                    } else {
                        _1ef(objs);
                    }
                    return false;
                });
            }
            if (opts.closable) {
                $("<a class=\"panel-tool-close\" href=\"javascript:void(0)\"></a>").appendTo(tool).bind("click",
                function() {
                    _1e1(objs);
                    return false;
                });
            }
            panelObj.children("div.panel-body").removeClass("panel-body-noheader");
        } else {
            panelObj.children("div.panel-body").addClass("panel-body-noheader");
        }
    };
    function refreshPanel(objs) {
        var panelObj = $.data(objs, "panel");
        var opts = panelObj.options;
        if (opts.href) {
            if (!panelObj.isLoaded || !opts.cache) {
                if (opts.onBeforeLoad.call(objs) == false) {
                    return;
                }
                panelObj.isLoaded = false;
                destroyPanelOther(objs);
                if (opts.loadingMessage) {
                    $(objs).html($("<div class='panel-loading'></div>").html(opts.loadingMessage));
                }
                $.ajax({
                    url: opts.href,
                    cache: false,
                    dataType: "html",
                    success: function(data) {
                        _1e6(opts.extractor.call(objs, data));
                        opts.onLoad.apply(objs, arguments);
                        panelObj.isLoaded = true;
                    }
                });
            }
        } else {
            if (opts.content) {
                if (!panelObj.isLoaded) {
                    destroyPanelOther(objs);
                    _1e6(opts.content);
                    panelObj.isLoaded = true;
                }
            }
        }
        function _1e6(_1e7) {
            $(objs).html(_1e7);
            if ($.parser) {
                $.parser.parse($(objs));
            }
        };
    };
    function destroyPanelOther(objs) {
        var t = $(objs);
        t.find(".combo-f").each(function() {
            $(this).combo("destroy");
        });
        t.find(".m-btn").each(function() {
            $(this).menubutton("destroy");
        });
        t.find(".s-btn").each(function() {
            $(this).splitbutton("destroy");
        });
        t.find(".tooltip-f").tooltip("destroy");
    };
    function resizePanel(objs) {
        $(objs).find("div.panel:visible,div.accordion:visible,div.tabs-container:visible,div.layout:visible").each(function() {
            $(this).triggerHandler("_resize", [true]);
        });
    };
    function _1eb(objs, bl) {
        var opts = $.data(objs, "panel").options;
        var panelObj = $.data(objs, "panel").panel;
        if (bl != true) {
            if (opts.onBeforeOpen.call(objs) == false) {
                return;
            }
        }
        panelObj.show();
        opts.closed = false;
        opts.minimized = false;
        var tool = panelObj.children("div.panel-header").find("a.panel-tool-restore");
        if (tool.length) {
            opts.maximized = true;
        }
        opts.onOpen.call(objs);
        if (opts.maximized == true) {
            opts.maximized = false;
            _1ef(objs);
        }
        if (opts.collapsed == true) {
            opts.collapsed = false;
            _1f0(objs);
        }
        if (!opts.collapsed) {
            refreshPanel(objs);
            resizePanel(objs);
        }
    };
    function _1e1(objs, bl) {
        var options = $.data(objs, "panel").options;
        var panelObj = $.data(objs, "panel").panel;
        if (bl != true) {
            if (options.onBeforeClose.call(objs) == false) {
                return;
            }
        }
        panelObj._fit(false);
        panelObj.hide();
        options.closed = true;
        options.onClose.call(objs);
    };
    function destroyPanel(objs, bl) {
        var options = $.data(objs, "panel").options;
        var panelObj = $.data(objs, "panel").panel;
        if (bl != true) {
            if (options.onBeforeDestroy.call(objs) == false) {
                return;
            }
        }
        destroyPanelOther(objs);
        removeHtmlNode(panelObj);
        options.onDestroy.call(objs);
    };
    function _1f0(objs, bl) {
        var opts = $.data(objs, "panel").options;
        var panelObj = $.data(objs, "panel").panel;
        var body = panelObj.children("div.panel-body");
        var tool = panelObj.children("div.panel-header").find("a.panel-tool-collapse");
        if (opts.collapsed == true) {
            return;
        }
        body.stop(true, true);
        if (opts.onBeforeCollapse.call(objs) == false) {
            return;
        }
        tool.addClass("panel-tool-expand");
        if (bl == true) {
            body.slideUp("normal",
            function() {
                opts.collapsed = true;
                opts.onCollapse.call(objs);
            });
        } else {
            body.hide();
            opts.collapsed = true;
            opts.onCollapse.call(objs);
        }
    };
    function expandPanel(objs, bl) {
        var opts = $.data(objs, "panel").options;
        var panelObj = $.data(objs, "panel").panel;
        var body = panelObj.children("div.panel-body");
        var tool = panelObj.children("div.panel-header").find("a.panel-tool-collapse");
        if (opts.collapsed == false) {
            return;
        }
        body.stop(true, true);
        if (opts.onBeforeExpand.call(objs) == false) {
            return;
        }
        tool.removeClass("panel-tool-expand");
        if (bl == true) {
            body.slideDown("normal", function() {
                opts.collapsed = false;
                opts.onExpand.call(objs);
                refreshPanel(objs);
                resizePanel(objs);
            });
        } else {
            body.show();
            opts.collapsed = false;
            opts.onExpand.call(objs);
            refreshPanel(objs);
            resizePanel(objs);
        }
    };
    function _1ef(objs) {
        var opts = $.data(objs, "panel").options;
        var panelObj = $.data(objs, "panel").panel;
        var tool = panelObj.children("div.panel-header").find("a.panel-tool-max");
        if (opts.maximized == true) {
            return;
        }
        tool.addClass("panel-tool-restore");
        if (!$.data(objs, "panel").original) {
            $.data(objs, "panel").original = {
                width: opts.width,
                height: opts.height,
                left: opts.left,
                top: opts.top,
                fit: opts.fit
            };
        }
        opts.left = 0;
        opts.top = 0;
        opts.fit = true;
        _1d0(objs);
        opts.minimized = false;
        opts.maximized = true;
        opts.onMaximize.call(objs);
    };
    function _201(objs) {
        var options = $.data(objs, "panel").options;
        var panelObj = $.data(objs, "panel").panel;
        panelObj._fit(false);
        panelObj.hide();
        options.minimized = true;
        options.maximized = false;
        options.onMinimize.call(objs);
    };
    function _204(objs) {
        var opts = $.data(objs, "panel").options;
        var panelObj = $.data(objs, "panel").panel;
        var tool = panelObj.children("div.panel-header").find("a.panel-tool-max");
        if (opts.maximized == false) {
            return;
        }
        panelObj.show();
        tool.removeClass("panel-tool-restore");
        $.extend(opts, $.data(objs, "panel").original);
        _1d0(objs);
        opts.minimized = false;
        opts.maximized = false;
        $.data(objs, "panel").original = null;
        opts.onRestore.call(objs);
    };
    function _207(objs) {
        var opts = $.data(objs, "panel").options;
        var panelObj = $.data(objs, "panel").panel;
        var header = $(objs).panel("header");
        var body = $(objs).panel("body");
        panelObj.css(opts.style);
        panelObj.addClass(opts.cls);
        if (opts.border) {
        	header.removeClass("panel-header-noborder");
            body.removeClass("panel-body-noborder");
        } else {
        	header.addClass("panel-header-noborder");
            body.addClass("panel-body-noborder");
        }
        header.addClass(opts.headerCls);
        body.addClass(opts.bodyCls);
        if (opts.id) {
            $(objs).attr("id", opts.id);
        } else {
            $(objs).attr("id", "");
        }
    };
    function setPanelTitle(objs, title) {
        $.data(objs, "panel").options.title = title;
        $(objs).panel("header").find("div.panel-title").html(title);
    };
    var TO = false;
    var _20e = true;
    $(window).unbind(".panel").bind("resize.panel",
    function() {
        if (!_20e) {
            return;
        }
        if (TO !== false) {
            clearTimeout(TO);
        }
        TO = setTimeout(function() {
            _20e = false;
            var _20f = $("body.layout");
            if (_20f.length) {
                _20f.layout("resize");
            } else {
                $("body").children("div.panel,div.accordion,div.tabs-container,div.layout").triggerHandler("_resize");
            }
            _20e = true;
            TO = false;
        },
        200);
    });
    $.fn.panel = function(params, bl) {
        if (typeof params == "string") {
            return $.fn.panel.methods[params](this, bl);
        }
        params = params || {};
        return this.each(function() {
            var panel = $.data(this, "panel");
            var opts;
            if (panel) {
                opts = $.extend(panel.options, params);
                panel.isLoaded = false;
            } else {
                opts = $.extend({},
                $.fn.panel.defaults, 
                $.fn.panel.parseOptions(this), 
                params);
                $(this).attr("title", "");
                panel = $.data(this, "panel", {
                    options: opts,
                    panel: getPanel(this),
                    isLoaded: false
                });
            }
            _1dd(this);
            _207(this);
            if (opts.doSize == true) {
                panel.panel.css("display", "block");
                _1d0(this);
            }
            if (opts.closed == true || opts.minimized == true) {
                panel.panel.hide();
            } else {
                _1eb(this);
            }
        });
    };
    $.fn.panel.methods = {
        options: function(jq) {
            return $.data(jq[0], "panel").options;
        },
        panel: function(jq) {
            return $.data(jq[0], "panel").panel;
        },
        header: function(jq) {
            return $.data(jq[0], "panel").panel.find(">div.panel-header");
        },
        body: function(jq) {
            return $.data(jq[0], "panel").panel.find(">div.panel-body");
        },
        setTitle: function(jq, title) {
            return jq.each(function() {
                setPanelTitle(this, title);
            });
        },
        open: function(jq, _214) {
            return jq.each(function() {
                _1eb(this, _214);
            });
        },
        close: function(jq, _215) {
            return jq.each(function() {
                _1e1(this, _215);
            });
        },
        destroy: function(jq, _216) {
            return jq.each(function() {
                destroyPanel(this, _216);
            });
        },
        refresh: function(jq, href) {
            return jq.each(function() {
                $.data(this, "panel").isLoaded = false;
                if (href) {
                    $.data(this, "panel").options.href = href;
                }
                refreshPanel(this);
            });
        },
        resize: function(jq, _217) {
            return jq.each(function() {
                _1d0(this, _217);
            });
        },
        move: function(jq, _218) {
            return jq.each(function() {
                _1d6(this, _218);
            });
        },
        maximize: function(jq) {
            return jq.each(function() {
                _1ef(this);
            });
        },
        minimize: function(jq) {
            return jq.each(function() {
                _201(this);
            });
        },
        restore: function(jq) {
            return jq.each(function() {
                _204(this);
            });
        },
        collapse: function(jq, _219) {
            return jq.each(function() {
                _1f0(this, _219);
            });
        },
        expand: function(jq, _21a) {
            return jq.each(function() {
                expandPanel(this, _21a);
            });
        }
    };
    $.fn.panel.parseOptions = function(objs) {
        var t = $(objs);
        return $.extend({},
        $.parser.parseOptions(
        	objs, 
        	["id", "width", "height", "left", "top", "title", "iconCls", "cls", "headerCls", "bodyCls", "tools", "href", 
        	 	{
		            cache: "boolean",
		            fit: "boolean",
		            border: "boolean",
		            noheader: "boolean"
        	 	},
		        {
		            collapsible: "boolean",
		            minimizable: "boolean",
		            maximizable: "boolean"
		        },
		        {
		            closable: "boolean",
		            collapsed: "boolean",
		            minimized: "boolean",
		            maximized: "boolean",
		            closed: "boolean"
		        }
		    ]
        ), {
            loadingMessage: (t.attr("loadingMessage") != undefined ? t.attr("loadingMessage") : undefined)
        });
    };
    $.fn.panel.defaults = {
        id: null,
        title: null,
        iconCls: null,
        width: "auto",
        height: "auto",
        left: null,
        top: null,
        cls: null,
        headerCls: null,
        bodyCls: null,
        style: {},
        href: null,
        cache: true,
        fit: false,
        border: true,
        doSize: true,
        noheader: false,
        content: null,
        collapsible: false,
        minimizable: false,
        maximizable: false,
        closable: false,
        collapsed: false,
        minimized: false,
        maximized: false,
        closed: false,
        tools: null,
        href: null,
        loadingMessage: "Loading...",
        extractor: function(data) {
            var _21c = /<body[^>]*>((.|[\n\r])*)<\/body>/im;
            var _21d = _21c.exec(data);
            if (_21d) {
                return _21d[1];
            } else {
                return data;
            }
        },
        onBeforeLoad: function() {},
        onLoad: function() {},
        onBeforeOpen: function() {},
        onOpen: function() {},
        onBeforeClose: function() {},
        onClose: function() {},
        onBeforeDestroy: function() {},
        onDestroy: function() {},
        onResize: function(_21e, _21f) {},
        onMove: function(left, top) {},
        onMaximize: function() {},
        onRestore: function() {},
        onMinimize: function() {},
        onBeforeCollapse: function() {},
        onBeforeExpand: function() {},
        onCollapse: function() {},
        onExpand: function() {}
    };
})(jQuery); 

//jquery.resizable
(function($) {
    $.fn.resizable = function(_58, _59) {
        if (typeof _58 == "string") {
            return $.fn.resizable.methods[_58](this, _59);
        }
        function _5a(e) {
            var _5b = e.data;
            var _5c = $.data(_5b.target, "resizable").options;
            if (_5b.dir.indexOf("e") != -1) {
                var _5d = _5b.startWidth + e.pageX - _5b.startX;
                _5d = Math.min(Math.max(_5d, _5c.minWidth), _5c.maxWidth);
                _5b.width = _5d;
            }
            if (_5b.dir.indexOf("s") != -1) {
                var _5e = _5b.startHeight + e.pageY - _5b.startY;
                _5e = Math.min(Math.max(_5e, _5c.minHeight), _5c.maxHeight);
                _5b.height = _5e;
            }
            if (_5b.dir.indexOf("w") != -1) {
                var _5d = _5b.startWidth - e.pageX + _5b.startX;
                _5d = Math.min(Math.max(_5d, _5c.minWidth), _5c.maxWidth);
                _5b.width = _5d;
                _5b.left = _5b.startLeft + _5b.startWidth - _5b.width;
            }
            if (_5b.dir.indexOf("n") != -1) {
                var _5e = _5b.startHeight - e.pageY + _5b.startY;
                _5e = Math.min(Math.max(_5e, _5c.minHeight), _5c.maxHeight);
                _5b.height = _5e;
                _5b.top = _5b.startTop + _5b.startHeight - _5b.height;
            }
        };
        function _5f(e) {
            var _60 = e.data;
            var t = $(_60.target);
            t.css({
                left: _60.left,
                top: _60.top
            });
            if (t.outerWidth() != _60.width) {
                t._outerWidth(_60.width);
            }
            if (t.outerHeight() != _60.height) {
                t._outerHeight(_60.height);
            }
        };
        function _61(e) {
            $.fn.resizable.isResizing = true;
            $.data(e.data.target, "resizable").options.onStartResize.call(e.data.target, e);
            return false;
        };
        function _62(e) {
            _5a(e);
            if ($.data(e.data.target, "resizable").options.onResize.call(e.data.target, e) != false) {
                _5f(e);
            }
            return false;
        };
        function _63(e) {
            $.fn.resizable.isResizing = false;
            _5a(e, true);
            _5f(e);
            $.data(e.data.target, "resizable").options.onStopResize.call(e.data.target, e);
            $(document).unbind(".resizable");
            $("body").css("cursor", "");
            return false;
        };
        return this.each(function() {
            var _64 = null;
            var _65 = $.data(this, "resizable");
            if (_65) {
                $(this).unbind(".resizable");
                _64 = $.extend(_65.options, _58 || {});
            } else {
                _64 = $.extend({},
                $.fn.resizable.defaults, $.fn.resizable.parseOptions(this), _58 || {});
                $.data(this, "resizable", {
                    options: _64
                });
            }
            if (_64.disabled == true) {
                return;
            }
            $(this).bind("mousemove.resizable", {
                target: this
            },
            function(e) {
                if ($.fn.resizable.isResizing) {
                    return;
                }
                var dir = _66(e);
                if (dir == "") {
                    $(e.data.target).css("cursor", "");
                } else {
                    $(e.data.target).css("cursor", dir + "-resize");
                }
            }).bind("mouseleave.resizable", {
                target: this
            },
            function(e) {
                $(e.data.target).css("cursor", "");
            }).bind("mousedown.resizable", {
                target: this
            },
            function(e) {
                var dir = _66(e);
                if (dir == "") {
                    return;
                }
                function _67(css) {
                    var val = parseInt($(e.data.target).css(css));
                    if (isNaN(val)) {
                        return 0;
                    } else {
                        return val;
                    }
                };
                var _68 = {
                    target: e.data.target,
                    dir: dir,
                    startLeft: _67("left"),
                    startTop: _67("top"),
                    left: _67("left"),
                    top: _67("top"),
                    startX: e.pageX,
                    startY: e.pageY,
                    startWidth: $(e.data.target).outerWidth(),
                    startHeight: $(e.data.target).outerHeight(),
                    width: $(e.data.target).outerWidth(),
                    height: $(e.data.target).outerHeight(),
                    deltaWidth: $(e.data.target).outerWidth() - $(e.data.target).width(),
                    deltaHeight: $(e.data.target).outerHeight() - $(e.data.target).height()
                };
                $(document).bind("mousedown.resizable", _68, _61);
                $(document).bind("mousemove.resizable", _68, _62);
                $(document).bind("mouseup.resizable", _68, _63);
                $("body").css("cursor", dir + "-resize");
            });
            function _66(e) {
                var tt = $(e.data.target);
                var dir = "";
                var _69 = tt.offset();
                var _6a = tt.outerWidth();
                var _6b = tt.outerHeight();
                var _6c = _64.edge;
                if (e.pageY > _69.top && e.pageY < _69.top + _6c) {
                    dir += "n";
                } else {
                    if (e.pageY < _69.top + _6b && e.pageY > _69.top + _6b - _6c) {
                        dir += "s";
                    }
                }
                if (e.pageX > _69.left && e.pageX < _69.left + _6c) {
                    dir += "w";
                } else {
                    if (e.pageX < _69.left + _6a && e.pageX > _69.left + _6a - _6c) {
                        dir += "e";
                    }
                }
                var _6d = _64.handles.split(",");
                for (var i = 0; i < _6d.length; i++) {
                    var _6e = _6d[i].replace(/(^\s*)|(\s*$)/g, "");
                    if (_6e == "all" || _6e == dir) {
                        return dir;
                    }
                }
                return "";
            };
        });
    };
    $.fn.resizable.methods = {
        options: function(jq) {
            return $.data(jq[0], "resizable").options;
        },
        enable: function(jq) {
            return jq.each(function() {
                $(this).resizable({
                    disabled: false
                });
            });
        },
        disable: function(jq) {
            return jq.each(function() {
                $(this).resizable({
                    disabled: true
                });
            });
        }
    };
    $.fn.resizable.parseOptions = function(_6f) {
        var t = $(_6f);
        return $.extend({},
        $.parser.parseOptions(_6f, ["handles", {
            minWidth: "number",
            minHeight: "number",
            maxWidth: "number",
            maxHeight: "number",
            edge: "number"
        }]), {
            disabled: (t.attr("disabled") ? true: undefined)
        });
    };
    $.fn.resizable.defaults = {
        disabled: false,
        handles: "n, e, s, w, ne, se, sw, nw, all",
        minWidth: 10,
        minHeight: 10,
        maxWidth: 10000,
        maxHeight: 10000,
        edge: 5,
        onStartResize: function(e) {},
        onResize: function(e) {},
        onStopResize: function(e) {}
    };
    $.fn.resizable.isResizing = false;
})(jQuery); 

//jquery.linkbutton
(function($) {
    function cstLb(obj) {
        var opts = $.data(obj, "linkbutton").options;
        var t = $(obj);
        t.addClass("l-btn").removeClass("l-btn-plain l-btn-selected l-btn-plain-selected");
        if (opts.plain) {
            t.addClass("l-btn-plain");
        }
        if (opts.selected) {
            t.addClass(opts.plain ? "l-btn-selected l-btn-plain-selected" : "l-btn-selected");
        }
        t.attr("group", opts.group || "");
        t.attr("id", opts.id || "");
        t.html("<span class='l-btn-left'>" + "<span class='l-btn-text'></span>" + "</span>");
        if (opts.text) {
            t.find(".l-btn-text").html(opts.text);
            if (opts.iconCls) {
                t.find(".l-btn-text").addClass(opts.iconCls).addClass(opts.iconAlign == "left" ? "l-btn-icon-left": "l-btn-icon-right");
            }
        } else {
            t.find(".l-btn-text").html("<span class='l-btn-empty'>&nbsp;</span>");
            if (opts.iconCls) {
                t.find(".l-btn-empty").addClass(opts.iconCls);
            }
        }
        t.unbind(".linkbutton").bind("focus.linkbutton", function() {
            if (!opts.disabled) {
                $(this).find(".l-btn-text").addClass("l-btn-focus");
            }
        }).bind("blur.linkbutton", function() {
            $(this).find(".l-btn-text").removeClass("l-btn-focus");
        });
        if (opts.toggle && !opts.disabled) {
            t.bind("click.linkbutton", function() {
                if (opts.selected) {
                    $(this).linkbutton("unselect");
                } else {
                    $(this).linkbutton("select");
                }
            });
        }
        setLbSelected(obj, opts.selected);
        setLbDisabled(obj, opts.disabled);
    };
    function setLbSelected(obj, selected) {
        var opts = $.data(obj, "linkbutton").options;
        if (selected) {
            if (opts.group) {
                $("a.l-btn[group='" + opts.group + "']").each(function() {
                    var o = $(this).linkbutton("options");
                    if (o.toggle) {
                        $(this).removeClass("l-btn-selected l-btn-plain-selected");
                        o.selected = false;
                    }
                });
            }
            $(obj).addClass(opts.plain ? "l-btn-selected l-btn-plain-selected": "l-btn-selected");
            opts.selected = true;
        } else {
            if (!opts.group) {
                $(obj).removeClass("l-btn-selected l-btn-plain-selected");
                opts.selected = false;
            }
        }
    };
    function setLbDisabled(obj, disabled) {
        var lb = $.data(obj, "linkbutton");
        var opts = lb.options;
        $(obj).removeClass("l-btn-disabled l-btn-plain-disabled");
        if (disabled) {
            opts.disabled = true;
            var href = $(obj).attr("href");
            if (href) {
                lb.href = href;
                $(obj).attr("href", "javascript:void(0)");
            }
            if (obj.onclick) {
                lb.onclick = obj.onclick;
                obj.onclick = null;
            }
            opts.plain ? $(obj).addClass("l-btn-disabled l-btn-plain-disabled") : $(obj).addClass("l-btn-disabled");
        } else {
            opts.disabled = false;
            if (lb.href) {
                $(obj).attr("href", lb.href);
            }
            if (lb.onclick) {
                obj.onclick = lb.onclick;
            }
        }
    };
    $.fn.linkbutton = function(params, other) {
        if (typeof params == "string") {
            return $.fn.linkbutton.methods[params](this, other);
        }
        params = params || {};
        return this.each(function() {
            var lb = $.data(this, "linkbutton");
            if (lb) {
                $.extend(lb.options, params);
            } else {
                $.data(this, "linkbutton", {
                    options: $.extend({},
                    $.fn.linkbutton.defaults, $.fn.linkbutton.parseOptions(this), params)
                });
                $(this).removeAttr("disabled");
            }
            cstLb(this);
        });
    };
    $.fn.linkbutton.methods = {
        options: function(jq) {
            return $.data(jq[0], "linkbutton").options;
        },
        enable: function(jq) {
            return jq.each(function() {
                setLbDisabled(this, false);
            });
        },
        disable: function(jq) {
            return jq.each(function() {
                setLbDisabled(this, true);
            });
        },
        select: function(jq) {
            return jq.each(function() {
                setLbSelected(this, true);
            });
        },
        unselect: function(jq) {
            return jq.each(function() {
                setLbSelected(this, false);
            });
        }
    };
    $.fn.linkbutton.parseOptions = function(obj) {
        var t = $(obj);
        return $.extend({},
        $.parser.parseOptions(obj, ["id", "iconCls", "iconAlign", "group", {
            plain: "boolean",
            toggle: "boolean",
            selected: "boolean"
        }]), {
            disabled: (t.attr("disabled") ? true: undefined),
            text: $.trim(t.html()),
            iconCls: (t.attr("icon") || t.attr("iconCls"))
        });
    };
    $.fn.linkbutton.defaults = {
        id: null,
        disabled: false,
        toggle: false,
        selected: false,
        group: null,
        plain: false,
        text: "",
        iconCls: null,
        iconAlign: "left"
    };
})(jQuery); 

//jquery.pagination
(function($) {
    function _81(obj) {
        var _83 = $.data(obj, "pagination");
        var opts = _83.options;
        var bb = _83.bb = {};
        var pgTbl = $(obj).addClass("pagination").html("<table cellspacing='0' cellpadding='0' border='0'><tr></tr></table>");
        var tr = pgTbl.find("tr");
        function go2OtherPage(_87) {
            var btn = opts.nav[_87];
            var a = $("<a href=\"javascript:void(0)\"></a>").appendTo(tr);
            a.wrap("<td></td>");
            a.linkbutton({
                iconCls: btn.iconCls,
                plain: true
            }).unbind(".pagination").bind("click.pagination",
            function() {
                btn.handler.call(obj);
            });
            return a;
        };
        if (opts.showPageList) {
            var ps = $("<select class=\"pagination-page-list\"></select>");
            ps.bind("change",
            function() {
                opts.pageSize = parseInt($(this).val());
                opts.onChangePageSize.call(obj, opts.pageSize);
                _89(obj, opts.pageNumber);
            });
            for (var i = 0; i < opts.pageList.length; i++) {
                $("<option></option>").text(opts.pageList[i]).appendTo(ps);
            }
            $("<td></td>").append(ps).appendTo(tr);
            $("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr);
        }
        bb.first = go2OtherPage("first");
        bb.prev = go2OtherPage("prev");
        $("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr);
        $("<span style=\"padding-left:6px;\"></span>").html(opts.beforePageText).appendTo(tr).wrap("<td></td>");
        bb.num = $("<input class=\"pagination-num\" type=\"text\" value=\"1\" size=\"2\">").appendTo(tr).wrap("<td></td>");
        bb.num.unbind(".pagination").bind("keydown.pagination",
        function(e) {
            if (e.keyCode == 13) {
                var _88 = parseInt($(this).val()) || 1;
                _89(obj, _88);
                return false;
            }
        });
        bb.after = $("<span style=\"padding-right:6px;\"></span>").appendTo(tr).wrap("<td></td>");
        $("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr);
        bb.next = go2OtherPage("next");
        bb.last = go2OtherPage("last");
        if (opts.showRefresh) {
            $("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr);
            bb.refresh = go2OtherPage("refresh");
        }
        if (opts.buttons) {
            $("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr);
            if ($.isArray(opts.buttons)) {
                for (var i = 0; i < opts.buttons.length; i++) {
                    var btn = opts.buttons[i];
                    if (btn == "-") {
                        $("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr);
                    } else {
                        var td = $("<td></td>").appendTo(tr);
                        var a = $("<a href=\"javascript:void(0)\"></a>").appendTo(td);
                        a[0].onclick = eval(btn.handler ||
                        function() {});
                        a.linkbutton($.extend({},
                        btn, {
                            plain: true
                        }));
                    }
                }
            } else {
                var td = $("<td></td>").appendTo(tr);
                $(opts.buttons).appendTo(td).show();
            }
        }
        $("<div class=\"pagination-info\"></div>").appendTo(pgTbl);
        $("<div style=\"clear:both;\"></div>").appendTo(pgTbl);
    };
    function _89(_8a, _8b) {
        var _8c = $.data(_8a, "pagination").options;
        _8d(_8a, {
            pageNumber: _8b
        });
        _8c.onSelectPage.call(_8a, _8c.pageNumber, _8c.pageSize);
    };
    function _8d(_8e, _8f) {
        var _90 = $.data(_8e, "pagination");
        var _91 = _90.options;
        var bb = _90.bb;
        $.extend(_91, _8f || {});
        var ps = $(_8e).find("select.pagination-page-list");
        if (ps.length) {
            ps.val(_91.pageSize + "");
            _91.pageSize = parseInt(ps.val());
        }
        var _92 = Math.ceil(_91.total / _91.pageSize) || 1;
        if (_91.pageNumber < 1) {
            _91.pageNumber = 1;
        }
        if (_91.pageNumber > _92) {
            _91.pageNumber = _92;
        }
        bb.num.val(_91.pageNumber);
        bb.after.html(_91.afterPageText.replace(/{pages}/, _92));
        var _93 = _91.displayMsg;
        _93 = _93.replace(/{from}/, _91.total == 0 ? 0 : _91.pageSize * (_91.pageNumber - 1) + 1);
        _93 = _93.replace(/{to}/, Math.min(_91.pageSize * (_91.pageNumber), _91.total));
        _93 = _93.replace(/{total}/, _91.total);
        $(_8e).find("div.pagination-info").html(_93);
        bb.first.add(bb.prev).linkbutton({
            disabled: (_91.pageNumber == 1)
        });
        bb.next.add(bb.last).linkbutton({
            disabled: (_91.pageNumber == _92)
        });
        _94(_8e, _91.loading);
    };
    function _94(_95, _96) {
        var _97 = $.data(_95, "pagination");
        var _98 = _97.options;
        var bb = _97.bb;
        _98.loading = _96;
        if (_98.showRefresh) {
            _97.bb.refresh.linkbutton({
                iconCls: (_98.loading ? "pagination-loading": "pagination-load")
            });
        }
    };
    $.fn.pagination = function(_99, _9a) {
        if (typeof _99 == "string") {
            return $.fn.pagination.methods[_99](this, _9a);
        }
        _99 = _99 || {};
        return this.each(function() {
            var _9b;
            var _9c = $.data(this, "pagination");
            if (_9c) {
                _9b = $.extend(_9c.options, _99);
            } else {
                _9b = $.extend({},
                $.fn.pagination.defaults, $.fn.pagination.parseOptions(this), _99);
                $.data(this, "pagination", {
                    options: _9b
                });
            }
            _81(this);
            _8d(this);
        });
    };
    $.fn.pagination.methods = {
        options: function(jq) {
            return $.data(jq[0], "pagination").options;
        },
        loading: function(jq) {
            return jq.each(function() {
                _94(this, true);
            });
        },
        loaded: function(jq) {
            return jq.each(function() {
                _94(this, false);
            });
        },
        refresh: function(jq, _9d) {
            return jq.each(function() {
                _8d(this, _9d);
            });
        },
        select: function(jq, _9e) {
            return jq.each(function() {
                _89(this, _9e);
            });
        }
    };
    $.fn.pagination.parseOptions = function(_9f) {
        var t = $(_9f);
        return $.extend({},
        $.parser.parseOptions(_9f, [{
            total: "number",
            pageSize: "number",
            pageNumber: "number"
        },
        {
            loading: "boolean",
            showPageList: "boolean",
            showRefresh: "boolean"
        }]), {
            pageList: (t.attr("pageList") ? eval(t.attr("pageList")) : undefined)
        });
    };
    $.fn.pagination.defaults = {
        total: 1,
        pageSize: 10,
        pageNumber: 1,
        pageList: [10, 20, 30, 50],
        loading: false,
        buttons: null,
        showPageList: true,
        showRefresh: true,
        onSelectPage: function(pageNumber, pageSize) {},
        onBeforeRefresh: function(_a2, _a3) {},
        onRefresh: function(_a4, _a5) {},
        onChangePageSize: function(_a6) {},
        beforePageText: "Page",
        afterPageText: "of {pages}",
        displayMsg: "Displaying {from} to {to} of {total} items",
        nav: {
            first: {
                iconCls: "pagination-first",
                handler: function() {
                    var _a7 = $(this).pagination("options");
                    if (_a7.pageNumber > 1) {
                        $(this).pagination("select", 1);
                    }
                }
            },
            prev: {
                iconCls: "pagination-prev",
                handler: function() {
                    var _a8 = $(this).pagination("options");
                    if (_a8.pageNumber > 1) {
                        $(this).pagination("select", _a8.pageNumber - 1);
                    }
                }
            },
            next: {
                iconCls: "pagination-next",
                handler: function() {
                    var _a9 = $(this).pagination("options");
                    var _aa = Math.ceil(_a9.total / _a9.pageSize);
                    if (_a9.pageNumber < _aa) {
                        $(this).pagination("select", _a9.pageNumber + 1);
                    }
                }
            },
            last: {
                iconCls: "pagination-last",
                handler: function() {
                    var _ab = $(this).pagination("options");
                    var _ac = Math.ceil(_ab.total / _ab.pageSize);
                    if (_ab.pageNumber < _ac) {
                        $(this).pagination("select", _ac);
                    }
                }
            },
            refresh: {
                iconCls: "pagination-refresh",
                handler: function() {
                    var _ad = $(this).pagination("options");
                    if (_ad.onBeforeRefresh.call(this, _ad.pageNumber, _ad.pageSize) != false) {
                        $(this).pagination("select", _ad.pageNumber);
                        _ad.onRefresh.call(this, _ad.pageNumber, _ad.pageSize);
                    }
                }
            }
        }
    };
})(jQuery);

//jquery.datagrid
(function($) {
    var _4a4 = 0;
    function _4a5(a, o) {
        for (var i = 0,
        len = a.length; i < len; i++) {
            if (a[i] == o) {
                return i;
            }
        }
        return - 1;
    };
    function _4a6(a, o, id) {
        if (typeof o == "string") {
            for (var i = 0,
            len = a.length; i < len; i++) {
                if (a[i][o] == id) {
                    a.splice(i, 1);
                    return;
                }
            }
        } else {
            var _4a7 = _4a5(a, o);
            if (_4a7 != -1) {
                a.splice(_4a7, 1);
            }
        }
    };
    function _4a8(a, o, r) {
        for (var i = 0,
        len = a.length; i < len; i++) {
            if (a[i][o] == r[o]) {
                return;
            }
        }
        a.push(r);
    };
    function _4a9(obj) {
        var cc = obj || $("head");
        var _4ab = $.data(cc[0], "ss");
        if (!_4ab) {
            _4ab = $.data(cc[0], "ss", {
                cache: {},
                dirty: []
            });
        }
        return {
            add: function(_4ac) {
                var ss = ["<style type=\"text/css\">"];
                for (var i = 0; i < _4ac.length; i++) {
                    _4ab.cache[_4ac[i][0]] = {
                        width: _4ac[i][1]
                    };
                }
                var _4ad = 0;
                for (var s in _4ab.cache) {
                    var item = _4ab.cache[s];
                    item.index = _4ad++;
                    ss.push(s + "{width:" + item.width + "}");
                }
                ss.push("</style>");
                $(ss.join("\n")).appendTo(cc);
                setTimeout(function() {
                    cc.children("style:not(:last)").remove();
                },
                0);
            },
            getRule: function(_4ae) {
                var _4af = cc.children("style:last")[0];
                var _4b0 = _4af.styleSheet ? _4af.styleSheet: (_4af.sheet || document.styleSheets[document.styleSheets.length - 1]);
                var _4b1 = _4b0.cssRules || _4b0.rules;
                return _4b1[_4ae];
            },
            set: function(_4b2, _4b3) {
                var item = _4ab.cache[_4b2];
                if (item) {
                    item.width = _4b3;
                    var rule = this.getRule(item.index);
                    if (rule) {
                        rule.style["width"] = _4b3;
                    }
                }
            },
            remove: function(_4b4) {
                var tmp = [];
                for (var s in _4ab.cache) {
                    if (s.indexOf(_4b4) == -1) {
                        tmp.push([s, _4ab.cache[s].width]);
                    }
                }
                _4ab.cache = {};
                this.add(tmp);
            },
            dirty: function(_4b5) {
                if (_4b5) {
                    _4ab.dirty.push(_4b5);
                }
            },
            clean: function() {
                for (var i = 0; i < _4ab.dirty.length; i++) {
                    this.remove(_4ab.dirty[i]);
                }
                _4ab.dirty = [];
            }
        };
    };
    function _4b6(obj, _4b8) {
        var opts = $.data(obj, "datagrid").options;
        var pnl = $.data(obj, "datagrid").panel;
        if (_4b8) {
            if (_4b8.width) {
                opts.width = _4b8.width;
            }
            if (_4b8.height) {
                opts.height = _4b8.height;
            }
        }
        if (opts.fit == true) {
            var p = pnl.panel("panel").parent();
            opts.width = p.width();
            opts.height = p.height();
        }
        pnl.panel("resize", {
            width: opts.width,
            height: opts.height
        });
    };
    function _4ba(_4bb) {
        var opts = $.data(_4bb, "datagrid").options;
        var dc = $.data(_4bb, "datagrid").dc;
        var wrap = $.data(_4bb, "datagrid").panel;
        var _4bc = wrap.width();
        var _4bd = wrap.height();
        var view = dc.view;
        var _4be = dc.view1;
        var _4bf = dc.view2;
        var _4c0 = _4be.children("div.datagrid-header");
        var _4c1 = _4bf.children("div.datagrid-header");
        var _4c2 = _4c0.find("table");
        var _4c3 = _4c1.find("table");
        view.width(_4bc);
        var _4c4 = _4c0.children("div.datagrid-header-inner").show();
        _4be.width(_4c4.find("table").width());
        if (!opts.showHeader) {
            _4c4.hide();
        }
        _4bf.width(_4bc - _4be._outerWidth());
        _4be.children("div.datagrid-header,div.datagrid-body,div.datagrid-footer").width(_4be.width());
        _4bf.children("div.datagrid-header,div.datagrid-body,div.datagrid-footer").width(_4bf.width());
        var hh;
        _4c0.css("height", "");
        _4c1.css("height", "");
        _4c2.css("height", "");
        _4c3.css("height", "");
        hh = Math.max(_4c2.height(), _4c3.height());
        _4c2.height(hh);
        _4c3.height(hh);
        _4c0.add(_4c1)._outerHeight(hh);
        if (opts.height != "auto") {
            var _4c5 = _4bd - _4bf.children("div.datagrid-header")._outerHeight() - _4bf.children("div.datagrid-footer")._outerHeight() - wrap.children("div.datagrid-toolbar")._outerHeight();
            wrap.children("div.datagrid-pager").each(function() {
                _4c5 -= $(this)._outerHeight();
            });
            dc.body1.add(dc.body2).children("table.datagrid-btable-frozen").css({
                position: "absolute",
                top: dc.header2._outerHeight()
            });
            var _4c6 = dc.body2.children("table.datagrid-btable-frozen")._outerHeight();
            _4be.add(_4bf).children("div.datagrid-body").css({
                marginTop: _4c6,
                height: (_4c5 - _4c6)
            });
        }
        view.height(_4bf.height());
    };
    function _4c7(_4c8, _4c9, _4ca) {
        var rows = $.data(_4c8, "datagrid").data.rows;
        var opts = $.data(_4c8, "datagrid").options;
        var dc = $.data(_4c8, "datagrid").dc;
        if (!dc.body1.is(":empty") && (!opts.nowrap || opts.autoRowHeight || _4ca)) {
            if (_4c9 != undefined) {
                var tr1 = opts.finder.getTr(_4c8, _4c9, "body", 1);
                var tr2 = opts.finder.getTr(_4c8, _4c9, "body", 2);
                _4cb(tr1, tr2);
            } else {
                var tr1 = opts.finder.getTr(_4c8, 0, "allbody", 1);
                var tr2 = opts.finder.getTr(_4c8, 0, "allbody", 2);
                _4cb(tr1, tr2);
                if (opts.showFooter) {
                    var tr1 = opts.finder.getTr(_4c8, 0, "allfooter", 1);
                    var tr2 = opts.finder.getTr(_4c8, 0, "allfooter", 2);
                    _4cb(tr1, tr2);
                }
            }
        }
        _4ba(_4c8);
        if (opts.height == "auto") {
            var _4cc = dc.body1.parent();
            var _4cd = dc.body2;
            var _4ce = _4cf(_4cd);
            var _4d0 = _4ce.height;
            if (_4ce.width > _4cd.width()) {
                _4d0 += 18;
            }
            _4cc.height(_4d0);
            _4cd.height(_4d0);
            dc.view.height(dc.view2.height());
        }
        dc.body2.triggerHandler("scroll");
        function _4cb(trs1, trs2) {
            for (var i = 0; i < trs2.length; i++) {
                var tr1 = $(trs1[i]);
                var tr2 = $(trs2[i]);
                tr1.css("height", "");
                tr2.css("height", "");
                var _4d1 = Math.max(tr1.height(), tr2.height());
                tr1.css("height", _4d1);
                tr2.css("height", _4d1);
            }
        };
        function _4cf(cc) {
            var _4d2 = 0;
            var _4d3 = 0;
            $(cc).children().each(function() {
                var c = $(this);
                if (c.is(":visible")) {
                    _4d3 += c._outerHeight();
                    if (_4d2 < c._outerWidth()) {
                        _4d2 = c._outerWidth();
                    }
                }
            });
            return {
                width: _4d2,
                height: _4d3
            };
        };
    };
    function _4d4(_4d5, _4d6) {
        var _4d7 = $.data(_4d5, "datagrid");
        var opts = _4d7.options;
        var dc = _4d7.dc;
        if (!dc.body2.children("table.datagrid-btable-frozen").length) {
            dc.body1.add(dc.body2).prepend("<table class=\"datagrid-btable datagrid-btable-frozen\" cellspacing=\"0\" cellpadding=\"0\"></table>");
        }
        _4d8(true);
        _4d8(false);
        _4ba(_4d5);
        function _4d8(_4d9) {
            var _4da = _4d9 ? 1 : 2;
            var tr = opts.finder.getTr(_4d5, _4d6, "body", _4da); (_4d9 ? dc.body1: dc.body2).children("table.datagrid-btable-frozen").append(tr);
        };
    };
    function parseCols(obj, rownumbers) {
        function getFrozenStatus() {
            var frozenCols = [];
            var unfrozenCols = [];
            $(obj).children("thead").each(function() {
                var opt = $.parser.parseOptions(this, [{
                    frozen: "boolean"
                }]);
                $(this).find("tr").each(function() {
                    var cols = [];
                    $(this).find("th").each(function() {
                        var th = $(this);
                        var col = $.extend({},
                        $.parser.parseOptions(this, ["field", "align", "halign", "order", {
                            sortable: "boolean",
                            checkbox: "boolean",
                            resizable: "boolean",
                            fixed: "boolean"
                        },
                        {
                            rowspan: "number",
                            colspan: "number",
                            width: "number"
                        }]), {
                            title: (th.html() || undefined),
                            hidden: (th.attr("hidden") ? true: undefined),
                            formatter: (th.attr("formatter") ? eval(th.attr("formatter")) : undefined),
                            styler: (th.attr("styler") ? eval(th.attr("styler")) : undefined),
                            sorter: (th.attr("sorter") ? eval(th.attr("sorter")) : undefined)
                        });
                        if (th.attr("editor")) {
                            var s = $.trim(th.attr("editor"));
                            if (s.substr(0, 1) == "{") {
                                col.editor = eval("(" + s + ")");
                            } else {
                                col.editor = s;
                            }
                        }
                        cols.push(col);
                    });
                    opt.frozen ? frozenCols.push(cols) : unfrozenCols.push(cols);
                });
            });
            return [frozenCols, unfrozenCols];
        };
        
        function getDatagridFrameworkHtml() {
        	var html = '';
        	html += "<div class='datagrid-wrap'>";
        	html += "	<div class='datagrid-view'>";
        	html += "		<div class='datagrid-view1'>";
        	html += "			<div class='datagrid-header'>";
        	html += "				<div class='datagrid-header-inner'></div>";
        	html += "			</div>";
        	html += "			<div class='datagrid-body'>";
        	html += "				<div class='datagrid-body-inner'></div>";
        	html += "			</div>";
        	html += "			<div class='datagrid-footer'>";
        	html += "				<div class='datagrid-footer-inner'></div>";
        	html += "			</div>";
        	html += "		</div>";
        	html += "		<div class='datagrid-view2'>";
        	html += "			<div class='datagrid-header'>";
        	html += "				<div class='datagrid-header-inner'></div>";
        	html += "			</div>";
        	html += "			<div class='datagrid-body'></div>";
        	html += "			<div class='datagrid-footer'>";
        	html += "				<div class='datagrid-footer-inner'></div>";
        	html += "			</div>";
        	html += "		</div>";
        	html += "	</div>";
        	html += "</div>";
        	return html;
        }
        
        /**
         * $(html).insertAfter(obj) 表示
         * 在obj对象后插入html，并且返回html所代表的jquery实例对象
         */
        var fwObj = $(getDatagridFrameworkHtml()).insertAfter(obj);
        //console.log('fwObj : ' + fwObj.html());
        
        fwObj.panel({
            doSize: false
        });
        fwObj.panel("panel").addClass("datagrid").bind("_resize", function(e, _4e2) {
            var opts = $.data(obj, "datagrid").options;
            if (opts.fit == true || _4e2) {
                _4b6(obj);
                setTimeout(function() {
                    if ($.data(obj, "datagrid")) {
                        _4e3(obj);
                    }
                },
                0);
            }
            return false;
        });
        $(obj).hide().appendTo(fwObj.children("div.datagrid-view"));
        var cc = getFrozenStatus();
        var view = fwObj.children("div.datagrid-view");
        var view1 = view.children("div.datagrid-view1");
        var view2 = view.children("div.datagrid-view2");
        var clsView = fwObj.closest("div.datagrid-view");
        if (!clsView.length) {
            clsView = view;
        }
        var ss = _4a9(clsView);
        return {
            panel: fwObj,
            frozenColumns: cc[0],
            columns: cc[1],
            dc: {
                view: view,
                view1: view1,
                view2: view2,
                header1: view1.children("div.datagrid-header").children("div.datagrid-header-inner"),
                header2: view2.children("div.datagrid-header").children("div.datagrid-header-inner"),
                body1: view1.children("div.datagrid-body").children("div.datagrid-body-inner"),
                body2: view2.children("div.datagrid-body"),
                footer1: view1.children("div.datagrid-footer").children("div.datagrid-footer-inner"),
                footer2: view2.children("div.datagrid-footer").children("div.datagrid-footer-inner")
            },
            ss: ss
        };
    };
    
    function cstDatagridTable(obj) {
        var datagrid = $.data(obj, "datagrid");
        var opts = datagrid.options;
        var dc = datagrid.dc;
        var pnl = datagrid.panel;
        pnl.panel($.extend({}, opts, {
            id: null,
            doSize: false,
            onResize: function(_4eb, _4ec) {
                setTimeout(function() {
                    if ($.data(obj, "datagrid")) {
                        _4ba(obj);
                        _513(obj);
                        opts.onResize.call(pnl, _4eb, _4ec);
                    }
                },
                0);
            },
            onExpand: function() {
                _4c7(obj);
                opts.onExpand.call(pnl);
            }
        }));
        datagrid.rowIdPrefix = "datagrid-row-r" + (++_4a4);
        datagrid.cellClassPrefix = "datagrid-cell-c" + _4a4;
        _4ed(dc.header1, opts.frozenColumns, true);
        _4ed(dc.header2, opts.columns, false);
        _4ee();
        dc.header1.add(dc.header2).css("display", opts.showHeader ? "block": "none");
        dc.footer1.add(dc.footer2).css("display", opts.showFooter ? "block": "none");
        
        //toolbar
        if (opts.toolbar) {
            if ($.isArray(opts.toolbar)) {
                $("div.datagrid-toolbar", pnl).remove();
                var tb = $("<div class='datagrid-toolbar'><table cellspacing='0' cellpadding='0'><tr></tr></table></div>").prependTo(pnl);
                var tr = tb.find("tr");
                for (var i = 0; i < opts.toolbar.length; i++) {
                    var btn = opts.toolbar[i];
                    if (btn == "-") {
                        $("<td><div class='datagrid-btn-separator'></div></td>").appendTo(tr);
                    } else {
                        var td = $("<td></td>").appendTo(tr);
                        var tool = $("<a href='javascript:void(0)'></a>").appendTo(td);
                        tool[0].onclick = eval(btn.handler || function() {});
                        tool.linkbutton($.extend({}, btn, {
                            plain: true
                        }));
                    }
                }
            } else {
                $(opts.toolbar).addClass("datagrid-toolbar").prependTo(pnl);
                $(opts.toolbar).show();
            }
        } else {
            $("div.datagrid-toolbar", pnl).remove();
        }
        
        //pager
        $("div.datagrid-pager", pnl).remove();
        if (opts.pagination) {
            var pgContainer = $("<div class='datagrid-pager'></div>");
            if (opts.pagePosition == "bottom") {
                pgContainer.appendTo(pnl);
            } else {
                if (opts.pagePosition == "top") {
                    pgContainer.addClass("datagrid-pager-top").prependTo(pnl);
                } else {
                    var ptop = $("<div class='datagrid-pager datagrid-pager-top'></div>").prependTo(pnl);
                    pgContainer.appendTo(pnl);
                    pgContainer = pgContainer.add(ptop);
                }
            }
            pgContainer.pagination({
                total: 0,
                pageNumber: opts.pageNumber,
                pageSize: opts.pageSize,
                pageList: opts.pageList,
                onSelectPage: function(pageNumber, pageSize) {
                    opts.pageNumber = pageNumber;
                    opts.pageSize = pageSize;
                    pgContainer.pagination("refresh", {
                        pageNumber: pageNumber,
                        pageSize: pageSize
                    });
                    _5d7(obj);
                }
            });
            opts.pageSize = pgContainer.pagination("options").pageSize;
        }
        function _4ed(_4f2, _4f3, _4f4) {
            if (!_4f3) {
                return;
            }
            $(_4f2).show();
            $(_4f2).empty();
            var _4f5 = [];
            var _4f6 = [];
            if (opts.sortName) {
                _4f5 = opts.sortName.split(",");
                _4f6 = opts.sortOrder.split(",");
            }
            var t = $("<table class=\"datagrid-htable\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tbody></tbody></table>").appendTo(_4f2);
            for (var i = 0; i < _4f3.length; i++) {
                var tr = $("<tr class=\"datagrid-header-row\"></tr>").appendTo($("tbody", t));
                var cols = _4f3[i];
                for (var j = 0; j < cols.length; j++) {
                    var col = cols[j];
                    var attr = "";
                    if (col.rowspan) {
                        attr += "rowspan=\"" + col.rowspan + "\" ";
                    }
                    if (col.colspan) {
                        attr += "colspan=\"" + col.colspan + "\" ";
                    }
                    var td = $("<td " + attr + "></td>").appendTo(tr);
                    if (col.checkbox) {
                        td.attr("field", col.field);
                        $("<div class=\"datagrid-header-check\"></div>").html("<input type=\"checkbox\"/>").appendTo(td);
                    } else {
                        if (col.field) {
                            td.attr("field", col.field);
                            td.append("<div class=\"datagrid-cell\"><span></span><span class=\"datagrid-sort-icon\"></span></div>");
                            $("span", td).html(col.title);
                            $("span.datagrid-sort-icon", td).html("&nbsp;");
                            var cell = td.find("div.datagrid-cell");
                            var pos = _4a5(_4f5, col.field);
                            if (pos >= 0) {
                                cell.addClass("datagrid-sort-" + _4f6[pos]);
                            }
                            if (col.resizable == false) {
                                cell.attr("resizable", "false");
                            }
                            if (col.width) {
                                cell._outerWidth(col.width);
                                col.boxWidth = parseInt(cell[0].style.width);
                            } else {
                                col.auto = true;
                            }
                            cell.css("text-align", (col.halign || col.align || ""));
                            col.cellClass = datagrid.cellClassPrefix + "-" + col.field.replace(/[\.|\s]/g, "-");
                        } else {
                            $("<div class=\"datagrid-cell-group\"></div>").html(col.title).appendTo(td);
                        }
                    }
                    if (col.hidden) {
                        td.hide();
                    }
                }
            }
            if (_4f4 && opts.rownumbers) {
                var td = $("<td rowspan=\"" + opts.frozenColumns.length + "\"><div class=\"datagrid-header-rownumber\"></div></td>");
                if ($("tr", t).length == 0) {
                    td.wrap("<tr class=\"datagrid-header-row\"></tr>").parent().appendTo($("tbody", t));
                } else {
                    td.prependTo($("tr:first", t));
                }
            }
        };
        function _4ee() {
            var _4f7 = [];
            var _4f8 = _4f9(obj, true).concat(_4f9(obj));
            for (var i = 0; i < _4f8.length; i++) {
                var col = _4fa(obj, _4f8[i]);
                if (col && !col.checkbox) {
                    _4f7.push(["." + col.cellClass, col.boxWidth ? col.boxWidth + "px": "auto"]);
                }
            }
            datagrid.ss.add(_4f7);
            datagrid.ss.dirty(datagrid.cellSelectorPrefix);
            datagrid.cellSelectorPrefix = "." + datagrid.cellClassPrefix;
        };
    };
    
    function _4fb(_4fc) {
        var _4fd = $.data(_4fc, "datagrid");
        var _4fe = _4fd.panel;
        var opts = _4fd.options;
        var dc = _4fd.dc;
        var _4ff = dc.header1.add(dc.header2);
        _4ff.find("input[type=checkbox]").unbind(".datagrid").bind("click.datagrid",
        function(e) {
            if (opts.singleSelect && opts.selectOnCheck) {
                return false;
            }
            if ($(this).is(":checked")) {
                _572(_4fc);
            } else {
                _578(_4fc);
            }
            e.stopPropagation();
        });
        var _500 = _4ff.find("div.datagrid-cell");
        _500.closest("td").unbind(".datagrid").bind("mouseenter.datagrid",
        function() {
            if (_4fd.resizing) {
                return;
            }
            $(this).addClass("datagrid-header-over");
        }).bind("mouseleave.datagrid",
        function() {
            $(this).removeClass("datagrid-header-over");
        }).bind("contextmenu.datagrid",
        function(e) {
            var _501 = $(this).attr("field");
            opts.onHeaderContextMenu.call(_4fc, e, _501);
        });
        _500.unbind(".datagrid").bind("click.datagrid",
        function(e) {
            var p1 = $(this).offset().left + 5;
            var p2 = $(this).offset().left + $(this)._outerWidth() - 5;
            if (e.pageX < p2 && e.pageX > p1) {
                var _502 = $(this).parent().attr("field");
                var col = _4fa(_4fc, _502);
                if (!col.sortable || _4fd.resizing) {
                    return;
                }
                var _503 = [];
                var _504 = [];
                if (opts.sortName) {
                    _503 = opts.sortName.split(",");
                    _504 = opts.sortOrder.split(",");
                }
                var pos = _4a5(_503, _502);
                var _505 = col.order || "asc";
                if (pos >= 0) {
                    $(this).removeClass("datagrid-sort-asc datagrid-sort-desc");
                    var _506 = _504[pos] == "asc" ? "desc": "asc";
                    if (opts.multiSort && _506 == _505) {
                        _503.splice(pos, 1);
                        _504.splice(pos, 1);
                    } else {
                        _504[pos] = _506;
                        $(this).addClass("datagrid-sort-" + _506);
                    }
                } else {
                    if (opts.multiSort) {
                        _503.push(_502);
                        _504.push(_505);
                    } else {
                        _503 = [_502];
                        _504 = [_505];
                        _500.removeClass("datagrid-sort-asc datagrid-sort-desc");
                    }
                    $(this).addClass("datagrid-sort-" + _505);
                }
                opts.sortName = _503.join(",");
                opts.sortOrder = _504.join(",");
                if (opts.remoteSort) {
                    _5d7(_4fc);
                } else {
                    var data = $.data(_4fc, "datagrid").data;
                    _53f(_4fc, data);
                }
                opts.onSortColumn.call(_4fc, opts.sortName, opts.sortOrder);
            }
        }).bind("dblclick.datagrid",
        function(e) {
            var p1 = $(this).offset().left + 5;
            var p2 = $(this).offset().left + $(this)._outerWidth() - 5;
            var cond = opts.resizeHandle == "right" ? (e.pageX > p2) : (opts.resizeHandle == "left" ? (e.pageX < p1) : (e.pageX < p1 || e.pageX > p2));
            if (cond) {
                var _507 = $(this).parent().attr("field");
                var col = _4fa(_4fc, _507);
                if (col.resizable == false) {
                    return;
                }
                $(_4fc).datagrid("autoSizeColumn", _507);
                col.auto = false;
            }
        });
        var _508 = opts.resizeHandle == "right" ? "e": (opts.resizeHandle == "left" ? "w": "e,w");
        _500.each(function() {
            $(this).resizable({
                handles: _508,
                disabled: ($(this).attr("resizable") ? $(this).attr("resizable") == "false": false),
                minWidth: 25,
                onStartResize: function(e) {
                    _4fd.resizing = true;
                    _4ff.css("cursor", $("body").css("cursor"));
                    if (!_4fd.proxy) {
                        _4fd.proxy = $("<div class=\"datagrid-resize-proxy\"></div>").appendTo(dc.view);
                    }
                    _4fd.proxy.css({
                        left: e.pageX - $(_4fe).offset().left - 1,
                        display: "none"
                    });
                    setTimeout(function() {
                        if (_4fd.proxy) {
                            _4fd.proxy.show();
                        }
                    },
                    500);
                },
                onResize: function(e) {
                    _4fd.proxy.css({
                        left: e.pageX - $(_4fe).offset().left - 1,
                        display: "block"
                    });
                    return false;
                },
                onStopResize: function(e) {
                    _4ff.css("cursor", "");
                    $(this).css("height", "");
                    var _509 = $(this).parent().attr("field");
                    var col = _4fa(_4fc, _509);
                    col.width = $(this)._outerWidth();
                    col.boxWidth = parseInt(this.style.width);
                    col.auto = undefined;
                    _4e3(_4fc, _509);
                    _4fd.proxy.remove();
                    _4fd.proxy = null;
                    if ($(this).parents("div:first.datagrid-header").parent().hasClass("datagrid-view1")) {
                        _4ba(_4fc);
                    }
                    _513(_4fc);
                    opts.onResizeColumn.call(_4fc, _509, col.width);
                    setTimeout(function() {
                        _4fd.resizing = false;
                    },
                    0);
                }
            });
        });
        dc.body1.add(dc.body2).unbind().bind("mouseover",
        function(e) {
            if (_4fd.resizing) {
                return;
            }
            var tr = $(e.target).closest("tr.datagrid-row");
            if (!_50a(tr)) {
                return;
            }
            var _50b = _50c(tr);
            _55a(_4fc, _50b);
            e.stopPropagation();
        }).bind("mouseout",
        function(e) {
            var tr = $(e.target).closest("tr.datagrid-row");
            if (!_50a(tr)) {
                return;
            }
            var _50d = _50c(tr);
            opts.finder.getTr(_4fc, _50d).removeClass("datagrid-row-over");
            e.stopPropagation();
        }).bind("click",
        function(e) {
            var tt = $(e.target);
            var tr = tt.closest("tr.datagrid-row");
            if (!_50a(tr)) {
                return;
            }
            var _50e = _50c(tr);
            if (tt.parent().hasClass("datagrid-cell-check")) {
                if (opts.singleSelect && opts.selectOnCheck) {
                    if (!opts.checkOnSelect) {
                        _578(_4fc, true);
                    }
                    _565(_4fc, _50e);
                } else {
                    if (tt.is(":checked")) {
                        _565(_4fc, _50e);
                    } else {
                        _56c(_4fc, _50e);
                    }
                }
            } else {
                var row = opts.finder.getRow(_4fc, _50e);
                var td = tt.closest("td[field]", tr);
                if (td.length) {
                    var _50f = td.attr("field");
                    opts.onClickCell.call(_4fc, _50e, _50f, row[_50f]);
                }
                if (opts.singleSelect == true) {
                    _55e(_4fc, _50e);
                } else {
                    if (tr.hasClass("datagrid-row-selected")) {
                        _566(_4fc, _50e);
                    } else {
                        _55e(_4fc, _50e);
                    }
                }
                opts.onClickRow.call(_4fc, _50e, row);
            }
            e.stopPropagation();
        }).bind("dblclick", function(e) {
            var tt = $(e.target);
            var tr = tt.closest("tr.datagrid-row");
            if (!_50a(tr)) {
                return;
            }
            var _510 = _50c(tr);
            var row = opts.finder.getRow(_4fc, _510);
            var td = tt.closest("td[field]", tr);
            if (td.length) {
                var _511 = td.attr("field");
                opts.onDblClickCell.call(_4fc, _510, _511, row[_511]);
            }
            opts.onDblClickRow.call(_4fc, _510, row);
            e.stopPropagation();
        }).bind("contextmenu", function(e) {
            var tr = $(e.target).closest("tr.datagrid-row");
            if (!_50a(tr)) {
                return;
            }
            var _512 = _50c(tr);
            var row = opts.finder.getRow(_4fc, _512);
            opts.onRowContextMenu.call(_4fc, e, _512, row);
            e.stopPropagation();
        });
        dc.body2.bind("scroll", function() {
            var b1 = dc.view1.children("div.datagrid-body");
            b1.scrollTop($(this).scrollTop());
            var c1 = dc.body1.children(":first");
            var c2 = dc.body2.children(":first");
            if (c1.length && c2.length) {
                var top1 = c1.offset().top;
                var top2 = c2.offset().top;
                if (top1 != top2) {
                    b1.scrollTop(b1.scrollTop() + top1 - top2);
                }
            }
            dc.view2.children("div.datagrid-header,div.datagrid-footer")._scrollLeft($(this)._scrollLeft());
            dc.body2.children("table.datagrid-btable-frozen").css("left", -$(this)._scrollLeft());
        });
        function _50c(tr) {
            if (tr.attr("datagrid-row-index")) {
                return parseInt(tr.attr("datagrid-row-index"));
            } else {
                return tr.attr("node-id");
            }
        };
        function _50a(tr) {
            return tr.length && tr.parent().length;
        };
    };
    function _513(_514) {
        var opts = $.data(_514, "datagrid").options;
        var dc = $.data(_514, "datagrid").dc;
        dc.body2.css("overflow-x", opts.fitColumns ? "hidden": "");
        if (!opts.fitColumns) {
            return;
        }
        var _515 = dc.view2.children("div.datagrid-header");
        var _516 = 0;
        var _517;
        var _518 = _4f9(_514, false);
        for (var i = 0; i < _518.length; i++) {
            var col = _4fa(_514, _518[i]);
            if (_519(col)) {
                _516 += col.width;
                _517 = col;
            }
        }
        var _51a = _515.children("div.datagrid-header-inner").show();
        var _51b = _515.width() - _515.find("table").width() - opts.scrollbarSize;
        var rate = _51b / _516;
        if (!opts.showHeader) {
            _51a.hide();
        }
        for (var i = 0; i < _518.length; i++) {
            var col = _4fa(_514, _518[i]);
            if (_519(col)) {
                var _51c = Math.floor(col.width * rate);
                _51d(col, _51c);
                _51b -= _51c;
            }
        }
        if (_51b && _517) {
            _51d(_517, _51b);
        }
        _4e3(_514);
        function _51d(col, _51e) {
            col.width += _51e;
            col.boxWidth += _51e;
            _515.find("td[field=\"" + col.field + "\"] div.datagrid-cell").width(col.boxWidth);
        };
        function _519(col) {
            if (!col.hidden && !col.checkbox && !col.auto && !col.fixed) {
                return true;
            }
        };
    };
    function _51f(_520, _521) {
        var opts = $.data(_520, "datagrid").options;
        var dc = $.data(_520, "datagrid").dc;
        if (_521) {
            _4b6(_521);
            if (opts.fitColumns) {
                _4ba(_520);
                _513(_520);
            }
        } else {
            var _522 = false;
            var _523 = _4f9(_520, true).concat(_4f9(_520, false));
            for (var i = 0; i < _523.length; i++) {
                var _521 = _523[i];
                var col = _4fa(_520, _521);
                if (col.auto) {
                    _4b6(_521);
                    _522 = true;
                }
            }
            if (_522 && opts.fitColumns) {
                _4ba(_520);
                _513(_520);
            }
        }
        function _4b6(_524) {
            var _525 = dc.view.find("div.datagrid-header td[field=\"" + _524 + "\"] div.datagrid-cell");
            _525.css("width", "");
            var col = $(_520).datagrid("getColumnOption", _524);
            col.width = undefined;
            col.boxWidth = undefined;
            col.auto = true;
            $(_520).datagrid("fixColumnSize", _524);
            var _526 = Math.max(_525._outerWidth(), _527("allbody"), _527("allfooter"));
            _525._outerWidth(_526);
            col.width = _526;
            col.boxWidth = parseInt(_525[0].style.width);
            $(_520).datagrid("fixColumnSize", _524);
            opts.onResizeColumn.call(_520, _524, col.width);
            function _527(type) {
                var _528 = 0;
                opts.finder.getTr(_520, 0, type).find("td[field=\"" + _524 + "\"] div.datagrid-cell").each(function() {
                    var w = $(this)._outerWidth();
                    if (_528 < w) {
                        _528 = w;
                    }
                });
                return _528;
            };
        };
    };
    function _4e3(_529, _52a) {
        var _52b = $.data(_529, "datagrid");
        var opts = _52b.options;
        var dc = _52b.dc;
        var _52c = dc.view.find("table.datagrid-btable,table.datagrid-ftable");
        _52c.css("table-layout", "fixed");
        if (_52a) {
            fix(_52a);
        } else {
            var ff = _4f9(_529, true).concat(_4f9(_529, false));
            for (var i = 0; i < ff.length; i++) {
                fix(ff[i]);
            }
        }
        _52c.css("table-layout", "auto");
        _52d(_529);
        setTimeout(function() {
            _4c7(_529);
            _532(_529);
        },
        0);
        function fix(_52e) {
            var col = _4fa(_529, _52e);
            if (!col.checkbox) {
                _52b.ss.set("." + col.cellClass, col.boxWidth ? col.boxWidth + "px": "auto");
            }
        };
    };
    function _52d(_52f) {
        var dc = $.data(_52f, "datagrid").dc;
        dc.body1.add(dc.body2).find("td.datagrid-td-merged").each(function() {
            var td = $(this);
            var _530 = td.attr("colspan") || 1;
            var _531 = _4fa(_52f, td.attr("field")).width;
            for (var i = 1; i < _530; i++) {
                td = td.next();
                _531 += _4fa(_52f, td.attr("field")).width + 1;
            }
            $(this).children("div.datagrid-cell")._outerWidth(_531);
        });
    };
    function _532(_533) {
        var dc = $.data(_533, "datagrid").dc;
        dc.view.find("div.datagrid-editable").each(function() {
            var cell = $(this);
            var _534 = cell.parent().attr("field");
            var col = $(_533).datagrid("getColumnOption", _534);
            cell._outerWidth(col.width);
            var ed = $.data(this, "datagrid.editor");
            if (ed.actions.resize) {
                ed.actions.resize(ed.target, cell.width());
            }
        });
    };
    function _4fa(_535, _536) {
        function find(_537) {
            if (_537) {
                for (var i = 0; i < _537.length; i++) {
                    var cc = _537[i];
                    for (var j = 0; j < cc.length; j++) {
                        var c = cc[j];
                        if (c.field == _536) {
                            return c;
                        }
                    }
                }
            }
            return null;
        };
        var opts = $.data(_535, "datagrid").options;
        var col = find(opts.columns);
        if (!col) {
            col = find(opts.frozenColumns);
        }
        return col;
    };
    function _4f9(_538, _539) {
        var opts = $.data(_538, "datagrid").options;
        var _53a = (_539 == true) ? (opts.frozenColumns || [[]]) : opts.columns;
        if (_53a.length == 0) {
            return [];
        }
        var _53b = [];
        function _53c(_53d) {
            var c = 0;
            var i = 0;
            while (true) {
                if (_53b[i] == undefined) {
                    if (c == _53d) {
                        return i;
                    }
                    c++;
                }
                i++;
            }
        };
        function _53e(r) {
            var ff = [];
            var c = 0;
            for (var i = 0; i < _53a[r].length; i++) {
                var col = _53a[r][i];
                if (col.field) {
                    ff.push([c, col.field]);
                }
                c += parseInt(col.colspan || "1");
            }
            for (var i = 0; i < ff.length; i++) {
                ff[i][0] = _53c(ff[i][0]);
            }
            for (var i = 0; i < ff.length; i++) {
                var f = ff[i];
                _53b[f[0]] = f[1];
            }
        };
        for (var i = 0; i < _53a.length; i++) {
            _53e(i);
        }
        return _53b;
    };
    function _53f(objs, data) {
        var datagrid = $.data(objs, "datagrid");
        var opts = datagrid.options;
        var dc = datagrid.dc;
        data = opts.loadFilter.call(objs, data);
        data.total = parseInt(data.total);
        datagrid.data = data;
        if (data.footer) {
            datagrid.footer = data.footer;
        }
        if (!opts.remoteSort && opts.sortName) {
            var snArr = opts.sortName.split(",");
            var soArr = opts.sortOrder.split(",");
            data.rows.sort(function(r1, r2) {
                var r = 0;
                for (var i = 0; i < snArr.length; i++) {
                    var sn = snArr[i];
                    var so = soArr[i];
                    var col = _4fa(objs, sn);
                    var _544 = col.sorter ||
                    function(a, b) {
                        return a == b ? 0 : (a > b ? 1 : -1);
                    };
                    r = _544(r1[sn], r2[sn]) * (so == "asc" ? 1 : -1);
                    if (r != 0) {
                        return r;
                    }
                }
                return r;
            });
        }
        if (opts.view.onBeforeRender) {
            opts.view.onBeforeRender.call(opts.view, objs, data.rows);
        }
        opts.view.render.call(opts.view, objs, dc.body2, false);
        opts.view.render.call(opts.view, objs, dc.body1, true);
        if (opts.showFooter) {
            opts.view.renderFooter.call(opts.view, objs, dc.footer2, false);
            opts.view.renderFooter.call(opts.view, objs, dc.footer1, true);
        }
        if (opts.view.onAfterRender) {
            opts.view.onAfterRender.call(opts.view, objs);
        }
        datagrid.ss.clean();
        opts.onLoadSuccess.call(objs, data);
        var pagerObjs = $(objs).datagrid("getPager");
        if (pagerObjs.length) {
            var pagerOptions = pagerObjs.pagination("options");
            if (pagerOptions.total != data.total) {
                pagerObjs.pagination("refresh", {
                    total: data.total
                });
                if (opts.pageNumber != pagerOptions.pageNumber) {
                    opts.pageNumber = pagerOptions.pageNumber;
                    _5d7(objs);
                }
            }
        }
        _4c7(objs);
        dc.body2.triggerHandler("scroll");
        _547();
        $(objs).datagrid("autoSizeColumn");
        function _547() {
            if (opts.idField) {
                for (var i = 0; i < data.rows.length; i++) {
                    var row = data.rows[i];
                    if (_548(datagrid.selectedRows, row)) {
                        opts.finder.getTr(objs, i).addClass("datagrid-row-selected");
                    }
                    if (_548(datagrid.checkedRows, row)) {
                        opts.finder.getTr(objs, i).find("div.datagrid-cell-check input[type=checkbox]")._propAttr("checked", true);
                    }
                }
            }
            function _548(a, r) {
                for (var i = 0; i < a.length; i++) {
                    if (a[i][opts.idField] == r[opts.idField]) {
                        a[i] = r;
                        return true;
                    }
                }
                return false;
            };
        };
    };
    function _549(_54a, row) {
        var _54b = $.data(_54a, "datagrid");
        var opts = _54b.options;
        var rows = _54b.data.rows;
        if (typeof row == "object") {
            return _4a5(rows, row);
        } else {
            for (var i = 0; i < rows.length; i++) {
                if (rows[i][opts.idField] == row) {
                    return i;
                }
            }
            return - 1;
        }
    };
    function _54c(_54d) {
        var _54e = $.data(_54d, "datagrid");
        var opts = _54e.options;
        var data = _54e.data;
        if (opts.idField) {
            return _54e.selectedRows;
        } else {
            var rows = [];
            opts.finder.getTr(_54d, "", "selected", 2).each(function() {
                var _54f = parseInt($(this).attr("datagrid-row-index"));
                rows.push(data.rows[_54f]);
            });
            return rows;
        }
    };
    function _550(_551) {
        var _552 = $.data(_551, "datagrid");
        var opts = _552.options;
        if (opts.idField) {
            return _552.checkedRows;
        } else {
            var rows = [];
            opts.finder.getTr(_551, "", "checked").each(function() {
                rows.push(opts.finder.getRow(_551, $(this)));
            });
            return rows;
        }
    };
    function _553(_554, _555) {
        var _556 = $.data(_554, "datagrid");
        var dc = _556.dc;
        var opts = _556.options;
        var tr = opts.finder.getTr(_554, _555);
        if (tr.length) {
            if (tr.closest("table").hasClass("datagrid-btable-frozen")) {
                return;
            }
            var _557 = dc.view2.children("div.datagrid-header")._outerHeight();
            var _558 = dc.body2;
            var _559 = _558.outerHeight(true) - _558.outerHeight();
            var top = tr.position().top - _557 - _559;
            if (top < 0) {
                _558.scrollTop(_558.scrollTop() + top);
            } else {
                if (top + tr._outerHeight() > _558.height() - 18) {
                    _558.scrollTop(_558.scrollTop() + top + tr._outerHeight() - _558.height() + 18);
                }
            }
        }
    };
    function _55a(_55b, _55c) {
        var _55d = $.data(_55b, "datagrid");
        var opts = _55d.options;
        opts.finder.getTr(_55b, _55d.highlightIndex).removeClass("datagrid-row-over");
        opts.finder.getTr(_55b, _55c).addClass("datagrid-row-over");
        _55d.highlightIndex = _55c;
    };
    function _55e(_55f, _560, _561) {
        var _562 = $.data(_55f, "datagrid");
        var dc = _562.dc;
        var opts = _562.options;
        var _563 = _562.selectedRows;
        if (opts.singleSelect) {
            _564(_55f);
            _563.splice(0, _563.length);
        }
        if (!_561 && opts.checkOnSelect) {
            _565(_55f, _560, true);
        }
        var row = opts.finder.getRow(_55f, _560);
        if (opts.idField) {
            _4a8(_563, opts.idField, row);
        }
        opts.finder.getTr(_55f, _560).addClass("datagrid-row-selected");
        opts.onSelect.call(_55f, _560, row);
        _553(_55f, _560);
    };
    function _566(_567, _568, _569) {
        var _56a = $.data(_567, "datagrid");
        var dc = _56a.dc;
        var opts = _56a.options;
        var _56b = $.data(_567, "datagrid").selectedRows;
        if (!_569 && opts.checkOnSelect) {
            _56c(_567, _568, true);
        }
        opts.finder.getTr(_567, _568).removeClass("datagrid-row-selected");
        var row = opts.finder.getRow(_567, _568);
        if (opts.idField) {
            _4a6(_56b, opts.idField, row[opts.idField]);
        }
        opts.onUnselect.call(_567, _568, row);
    };
    function _56d(_56e, _56f) {
        var _570 = $.data(_56e, "datagrid");
        var opts = _570.options;
        var rows = _570.data.rows;
        var _571 = $.data(_56e, "datagrid").selectedRows;
        if (!_56f && opts.checkOnSelect) {
            _572(_56e, true);
        }
        opts.finder.getTr(_56e, "", "allbody").addClass("datagrid-row-selected");
        if (opts.idField) {
            for (var _573 = 0; _573 < rows.length; _573++) {
                _4a8(_571, opts.idField, rows[_573]);
            }
        }
        opts.onSelectAll.call(_56e, rows);
    };
    function _564(_574, _575) {
        var _576 = $.data(_574, "datagrid");
        var opts = _576.options;
        var rows = _576.data.rows;
        var _577 = $.data(_574, "datagrid").selectedRows;
        if (!_575 && opts.checkOnSelect) {
            _578(_574, true);
        }
        opts.finder.getTr(_574, "", "selected").removeClass("datagrid-row-selected");
        if (opts.idField) {
            for (var _579 = 0; _579 < rows.length; _579++) {
                _4a6(_577, opts.idField, rows[_579][opts.idField]);
            }
        }
        opts.onUnselectAll.call(_574, rows);
    };
    function _565(_57a, _57b, _57c) {
        var _57d = $.data(_57a, "datagrid");
        var opts = _57d.options;
        if (!_57c && opts.selectOnCheck) {
            _55e(_57a, _57b, true);
        }
        var ck = opts.finder.getTr(_57a, _57b).find("div.datagrid-cell-check input[type=checkbox]");
        ck._propAttr("checked", true);
        ck = opts.finder.getTr(_57a, "", "checked");
        if (ck.length == _57d.data.rows.length) {
            var dc = _57d.dc;
            var _57e = dc.header1.add(dc.header2);
            _57e.find("input[type=checkbox]")._propAttr("checked", true);
        }
        var row = opts.finder.getRow(_57a, _57b);
        if (opts.idField) {
            _4a8(_57d.checkedRows, opts.idField, row);
        }
        opts.onCheck.call(_57a, _57b, row);
    };
    function _56c(_57f, _580, _581) {
        var _582 = $.data(_57f, "datagrid");
        var opts = _582.options;
        if (!_581 && opts.selectOnCheck) {
            _566(_57f, _580, true);
        }
        var ck = opts.finder.getTr(_57f, _580).find("div.datagrid-cell-check input[type=checkbox]");
        ck._propAttr("checked", false);
        var dc = _582.dc;
        var _583 = dc.header1.add(dc.header2);
        _583.find("input[type=checkbox]")._propAttr("checked", false);
        var row = opts.finder.getRow(_57f, _580);
        if (opts.idField) {
            _4a6(_582.checkedRows, opts.idField, row[opts.idField]);
        }
        opts.onUncheck.call(_57f, _580, row);
    };
    function _572(_584, _585) {
        var _586 = $.data(_584, "datagrid");
        var opts = _586.options;
        var rows = _586.data.rows;
        if (!_585 && opts.selectOnCheck) {
            _56d(_584, true);
        }
        var dc = _586.dc;
        var hck = dc.header1.add(dc.header2).find("input[type=checkbox]");
        var bck = opts.finder.getTr(_584, "", "allbody").find("div.datagrid-cell-check input[type=checkbox]");
        hck.add(bck)._propAttr("checked", true);
        if (opts.idField) {
            for (var i = 0; i < rows.length; i++) {
                _4a8(_586.checkedRows, opts.idField, rows[i]);
            }
        }
        opts.onCheckAll.call(_584, rows);
    };
    function _578(_587, _588) {
        var _589 = $.data(_587, "datagrid");
        var opts = _589.options;
        var rows = _589.data.rows;
        if (!_588 && opts.selectOnCheck) {
            _564(_587, true);
        }
        var dc = _589.dc;
        var hck = dc.header1.add(dc.header2).find("input[type=checkbox]");
        var bck = opts.finder.getTr(_587, "", "allbody").find("div.datagrid-cell-check input[type=checkbox]");
        hck.add(bck)._propAttr("checked", false);
        if (opts.idField) {
            for (var i = 0; i < rows.length; i++) {
                _4a6(_589.checkedRows, opts.idField, rows[i][opts.idField]);
            }
        }
        opts.onUncheckAll.call(_587, rows);
    };
    function _58a(_58b, _58c) {
        var opts = $.data(_58b, "datagrid").options;
        var tr = opts.finder.getTr(_58b, _58c);
        var row = opts.finder.getRow(_58b, _58c);
        if (tr.hasClass("datagrid-row-editing")) {
            return;
        }
        if (opts.onBeforeEdit.call(_58b, _58c, row) == false) {
            return;
        }
        tr.addClass("datagrid-row-editing");
        _58d(_58b, _58c);
        _532(_58b);
        tr.find("div.datagrid-editable").each(function() {
            var _58e = $(this).parent().attr("field");
            var ed = $.data(this, "datagrid.editor");
            ed.actions.setValue(ed.target, row[_58e]);
        });
        _58f(_58b, _58c);
    };
    function _590(_591, _592, _593) {
        var opts = $.data(_591, "datagrid").options;
        var _594 = $.data(_591, "datagrid").updatedRows;
        var _595 = $.data(_591, "datagrid").insertedRows;
        var tr = opts.finder.getTr(_591, _592);
        var row = opts.finder.getRow(_591, _592);
        if (!tr.hasClass("datagrid-row-editing")) {
            return;
        }
        if (!_593) {
            if (!_58f(_591, _592)) {
                return;
            }
            var _596 = false;
            var _597 = {};
            tr.find("div.datagrid-editable").each(function() {
                var _598 = $(this).parent().attr("field");
                var ed = $.data(this, "datagrid.editor");
                var _599 = ed.actions.getValue(ed.target);
                if (row[_598] != _599) {
                    row[_598] = _599;
                    _596 = true;
                    _597[_598] = _599;
                }
            });
            if (_596) {
                if (_4a5(_595, row) == -1) {
                    if (_4a5(_594, row) == -1) {
                        _594.push(row);
                    }
                }
            }
        }
        tr.removeClass("datagrid-row-editing");
        _59a(_591, _592);
        $(_591).datagrid("refreshRow", _592);
        if (!_593) {
            opts.onAfterEdit.call(_591, _592, row, _597);
        } else {
            opts.onCancelEdit.call(_591, _592, row);
        }
    };
    function _59b(_59c, _59d) {
        var opts = $.data(_59c, "datagrid").options;
        var tr = opts.finder.getTr(_59c, _59d);
        var _59e = [];
        tr.children("td").each(function() {
            var cell = $(this).find("div.datagrid-editable");
            if (cell.length) {
                var ed = $.data(cell[0], "datagrid.editor");
                _59e.push(ed);
            }
        });
        return _59e;
    };
    function _59f(_5a0, _5a1) {
        var _5a2 = _59b(_5a0, _5a1.index);
        for (var i = 0; i < _5a2.length; i++) {
            if (_5a2[i].field == _5a1.field) {
                return _5a2[i];
            }
        }
        return null;
    };
    function _58d(_5a3, _5a4) {
        var opts = $.data(_5a3, "datagrid").options;
        var tr = opts.finder.getTr(_5a3, _5a4);
        tr.children("td").each(function() {
            var cell = $(this).find("div.datagrid-cell");
            var _5a5 = $(this).attr("field");
            var col = _4fa(_5a3, _5a5);
            if (col && col.editor) {
                var _5a6, _5a7;
                if (typeof col.editor == "string") {
                    _5a6 = col.editor;
                } else {
                    _5a6 = col.editor.type;
                    _5a7 = col.editor.options;
                }
                var _5a8 = opts.editors[_5a6];
                if (_5a8) {
                    var _5a9 = cell.html();
                    var _5aa = cell._outerWidth();
                    cell.addClass("datagrid-editable");
                    cell._outerWidth(_5aa);
                    cell.html("<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\"><tr><td></td></tr></table>");
                    cell.children("table").bind("click dblclick contextmenu",
                    function(e) {
                        e.stopPropagation();
                    });
                    $.data(cell[0], "datagrid.editor", {
                        actions: _5a8,
                        target: _5a8.init(cell.find("td"), _5a7),
                        field: _5a5,
                        type: _5a6,
                        oldHtml: _5a9
                    });
                }
            }
        });
        _4c7(_5a3, _5a4, true);
    };
    function _59a(_5ab, _5ac) {
        var opts = $.data(_5ab, "datagrid").options;
        var tr = opts.finder.getTr(_5ab, _5ac);
        tr.children("td").each(function() {
            var cell = $(this).find("div.datagrid-editable");
            if (cell.length) {
                var ed = $.data(cell[0], "datagrid.editor");
                if (ed.actions.destroy) {
                    ed.actions.destroy(ed.target);
                }
                cell.html(ed.oldHtml);
                $.removeData(cell[0], "datagrid.editor");
                cell.removeClass("datagrid-editable");
                cell.css("width", "");
            }
        });
    };
    function _58f(_5ad, _5ae) {
        var tr = $.data(_5ad, "datagrid").options.finder.getTr(_5ad, _5ae);
        if (!tr.hasClass("datagrid-row-editing")) {
            return true;
        }
        var vbox = tr.find(".validatebox-text");
        vbox.validatebox("validate");
        vbox.trigger("mouseleave");
        var _5af = tr.find(".validatebox-invalid");
        return _5af.length == 0;
    };
    function _5b0(_5b1, _5b2) {
        var _5b3 = $.data(_5b1, "datagrid").insertedRows;
        var _5b4 = $.data(_5b1, "datagrid").deletedRows;
        var _5b5 = $.data(_5b1, "datagrid").updatedRows;
        if (!_5b2) {
            var rows = [];
            rows = rows.concat(_5b3);
            rows = rows.concat(_5b4);
            rows = rows.concat(_5b5);
            return rows;
        } else {
            if (_5b2 == "inserted") {
                return _5b3;
            } else {
                if (_5b2 == "deleted") {
                    return _5b4;
                } else {
                    if (_5b2 == "updated") {
                        return _5b5;
                    }
                }
            }
        }
        return [];
    };
    function _5b6(_5b7, _5b8) {
        var _5b9 = $.data(_5b7, "datagrid");
        var opts = _5b9.options;
        var data = _5b9.data;
        var _5ba = _5b9.insertedRows;
        var _5bb = _5b9.deletedRows;
        $(_5b7).datagrid("cancelEdit", _5b8);
        var row = data.rows[_5b8];
        if (_4a5(_5ba, row) >= 0) {
            _4a6(_5ba, row);
        } else {
            _5bb.push(row);
        }
        _4a6(_5b9.selectedRows, opts.idField, data.rows[_5b8][opts.idField]);
        _4a6(_5b9.checkedRows, opts.idField, data.rows[_5b8][opts.idField]);
        opts.view.deleteRow.call(opts.view, _5b7, _5b8);
        if (opts.height == "auto") {
            _4c7(_5b7);
        }
        $(_5b7).datagrid("getPager").pagination("refresh", {
            total: data.total
        });
    };
    function _5bc(_5bd, _5be) {
        var data = $.data(_5bd, "datagrid").data;
        var view = $.data(_5bd, "datagrid").options.view;
        var _5bf = $.data(_5bd, "datagrid").insertedRows;
        view.insertRow.call(view, _5bd, _5be.index, _5be.row);
        _5bf.push(_5be.row);
        $(_5bd).datagrid("getPager").pagination("refresh", {
            total: data.total
        });
    };
    function _5c0(_5c1, row) {
        var data = $.data(_5c1, "datagrid").data;
        var view = $.data(_5c1, "datagrid").options.view;
        var _5c2 = $.data(_5c1, "datagrid").insertedRows;
        view.insertRow.call(view, _5c1, null, row);
        _5c2.push(row);
        $(_5c1).datagrid("getPager").pagination("refresh", {
            total: data.total
        });
    };
    function _5c3(_5c4) {
        var _5c5 = $.data(_5c4, "datagrid");
        var data = _5c5.data;
        var rows = data.rows;
        var _5c6 = [];
        for (var i = 0; i < rows.length; i++) {
            _5c6.push($.extend({},
            rows[i]));
        }
        _5c5.originalRows = _5c6;
        _5c5.updatedRows = [];
        _5c5.insertedRows = [];
        _5c5.deletedRows = [];
    };
    function _5c7(_5c8) {
        var data = $.data(_5c8, "datagrid").data;
        var ok = true;
        for (var i = 0,
        len = data.rows.length; i < len; i++) {
            if (_58f(_5c8, i)) {
                _590(_5c8, i, false);
            } else {
                ok = false;
            }
        }
        if (ok) {
            _5c3(_5c8);
        }
    };
    function _5c9(_5ca) {
        var _5cb = $.data(_5ca, "datagrid");
        var opts = _5cb.options;
        var _5cc = _5cb.originalRows;
        var _5cd = _5cb.insertedRows;
        var _5ce = _5cb.deletedRows;
        var _5cf = _5cb.selectedRows;
        var _5d0 = _5cb.checkedRows;
        var data = _5cb.data;
        function _5d1(a) {
            var ids = [];
            for (var i = 0; i < a.length; i++) {
                ids.push(a[i][opts.idField]);
            }
            return ids;
        };
        function _5d2(ids, _5d3) {
            for (var i = 0; i < ids.length; i++) {
                var _5d4 = _549(_5ca, ids[i]);
                if (_5d4 >= 0) { (_5d3 == "s" ? _55e: _565)(_5ca, _5d4, true);
                }
            }
        };
        for (var i = 0; i < data.rows.length; i++) {
            _590(_5ca, i, true);
        }
        var _5d5 = _5d1(_5cf);
        var _5d6 = _5d1(_5d0);
        _5cf.splice(0, _5cf.length);
        _5d0.splice(0, _5d0.length);
        data.total += _5ce.length - _5cd.length;
        data.rows = _5cc;
        _53f(_5ca, data);
        _5d2(_5d5, "s");
        _5d2(_5d6, "c");
        _5c3(_5ca);
    };
    function _5d7(objs, gp) {
        var opts = $.data(objs, "datagrid").options;
        if (gp) {
            opts.queryParams = gp;
        }
        var queryParams = $.extend({}, opts.queryParams);
        if (opts.pagination) {
            $.extend(queryParams, {
                page: opts.pageNumber,
                rows: opts.pageSize
            });
        }
        if (opts.sortName) {
            $.extend(queryParams, {
                sort: opts.sortName,
                order: opts.sortOrder
            });
        }
        if (opts.onBeforeLoad.call(objs, queryParams) == false) {
            return;
        }
        $(objs).datagrid("loading");
        setTimeout(function() {
            _5db();
        },
        0);
        function _5db() {
            var _5dc = opts.loader.call(objs, queryParams,
            function(data) {
                setTimeout(function() {
                    $(objs).datagrid("loaded");
                },
                0);
                _53f(objs, data);
                setTimeout(function() {
                    _5c3(objs);
                },
                0);
            },
            function() {
                setTimeout(function() {
                    $(objs).datagrid("loaded");
                },
                0);
                opts.onLoadError.apply(objs, arguments);
            });
            if (_5dc == false) {
                $(objs).datagrid("loaded");
            }
        };
    };
    function _5dd(_5de, _5df) {
        var opts = $.data(_5de, "datagrid").options;
        _5df.rowspan = _5df.rowspan || 1;
        _5df.colspan = _5df.colspan || 1;
        if (_5df.rowspan == 1 && _5df.colspan == 1) {
            return;
        }
        var tr = opts.finder.getTr(_5de, (_5df.index != undefined ? _5df.index: _5df.id));
        if (!tr.length) {
            return;
        }
        var row = opts.finder.getRow(_5de, tr);
        var _5e0 = row[_5df.field];
        var td = tr.find("td[field=\"" + _5df.field + "\"]");
        td.attr("rowspan", _5df.rowspan).attr("colspan", _5df.colspan);
        td.addClass("datagrid-td-merged");
        for (var i = 1; i < _5df.colspan; i++) {
            td = td.next();
            td.hide();
            row[td.attr("field")] = _5e0;
        }
        for (var i = 1; i < _5df.rowspan; i++) {
            tr = tr.next();
            if (!tr.length) {
                break;
            }
            var row = opts.finder.getRow(_5de, tr);
            var td = tr.find("td[field=\"" + _5df.field + "\"]").hide();
            row[td.attr("field")] = _5e0;
            for (var j = 1; j < _5df.colspan; j++) {
                td = td.next();
                td.hide();
                row[td.attr("field")] = _5e0;
            }
        }
        _52d(_5de);
    };
    
    /**
     * jquery.datagrid 入口
     * 如$('#test').datagrid();
     * this指$('#test')对象
     */
    $.fn.datagrid = function(params, bl) {
        if (typeof params == "string") {
            return $.fn.datagrid.methods[params](this, bl);
        }
        params = params || {};
        return this.each(function() {
            var datagrid = $.data(this, "datagrid");
            var opts;
            if (datagrid) {
                opts = $.extend(datagrid.options, params);
                datagrid.options = opts;
            } else {
                opts = $.extend({},
	                $.extend({},
		                $.fn.datagrid.defaults, 
		                {queryParams: {}}
	                ), 
	                $.fn.datagrid.parseOptions(this), 
	                params
                );
                $(this).css("width", "").css("height", "");
                var psResult = parseCols(this, opts.rownumbers);
                if (!opts.columns) {
                    opts.columns = psResult.columns;
                }
                if (!opts.frozenColumns) {
                    opts.frozenColumns = psResult.frozenColumns;
                }
                opts.columns = $.extend(true, [], opts.columns);
                opts.frozenColumns = $.extend(true, [], opts.frozenColumns);
                opts.view = $.extend({}, 
                	opts.view
                );
                $.data(this, "datagrid", {
                    options: opts,
                    panel: psResult.panel,
                    dc: psResult.dc,
                    ss: psResult.ss,
                    selectedRows: [],
                    checkedRows: [],
                    data: {
                        total: 0,
                        rows: []
                    },
                    originalRows: [],
                    updatedRows: [],
                    insertedRows: [],
                    deletedRows: []
                });
            }
            cstDatagridTable(this);
            if (opts.data) {
                _53f(this, opts.data);
                _5c3(this);
            } else {
                var data = $.fn.datagrid.parseData(this);
                if (data.total > 0) {
                    _53f(this, data);
                    _5c3(this);
                }
            }
            _4b6(this);
            _5d7(this);
            _4fb(this);
        });
    };
    
    var _5e5 = {
        text: {
            init: function(_5e6, _5e7) {
                var _5e8 = $("<input type=\"text\" class=\"datagrid-editable-input\">").appendTo(_5e6);
                return _5e8;
            },
            getValue: function(_5e9) {
                return $(_5e9).val();
            },
            setValue: function(_5ea, _5eb) {
                $(_5ea).val(_5eb);
            },
            resize: function(_5ec, _5ed) {
                $(_5ec)._outerWidth(_5ed)._outerHeight(22);
            }
        },
        textarea: {
            init: function(_5ee, _5ef) {
                var _5f0 = $("<textarea class=\"datagrid-editable-input\"></textarea>").appendTo(_5ee);
                return _5f0;
            },
            getValue: function(_5f1) {
                return $(_5f1).val();
            },
            setValue: function(_5f2, _5f3) {
                $(_5f2).val(_5f3);
            },
            resize: function(_5f4, _5f5) {
                $(_5f4)._outerWidth(_5f5);
            }
        },
        checkbox: {
            init: function(_5f6, _5f7) {
                var _5f8 = $("<input type=\"checkbox\">").appendTo(_5f6);
                _5f8.val(_5f7.on);
                _5f8.attr("offval", _5f7.off);
                return _5f8;
            },
            getValue: function(_5f9) {
                if ($(_5f9).is(":checked")) {
                    return $(_5f9).val();
                } else {
                    return $(_5f9).attr("offval");
                }
            },
            setValue: function(_5fa, _5fb) {
                var _5fc = false;
                if ($(_5fa).val() == _5fb) {
                    _5fc = true;
                }
                $(_5fa)._propAttr("checked", _5fc);
            }
        },
        numberbox: {
            init: function(_5fd, _5fe) {
                var _5ff = $("<input type=\"text\" class=\"datagrid-editable-input\">").appendTo(_5fd);
                _5ff.numberbox(_5fe);
                return _5ff;
            },
            destroy: function(_600) {
                $(_600).numberbox("destroy");
            },
            getValue: function(_601) {
                $(_601).blur();
                return $(_601).numberbox("getValue");
            },
            setValue: function(_602, _603) {
                $(_602).numberbox("setValue", _603);
            },
            resize: function(_604, _605) {
                $(_604)._outerWidth(_605)._outerHeight(22);
            }
        },
        validatebox: {
            init: function(_606, _607) {
                var _608 = $("<input type=\"text\" class=\"datagrid-editable-input\">").appendTo(_606);
                _608.validatebox(_607);
                return _608;
            },
            destroy: function(_609) {
                $(_609).validatebox("destroy");
            },
            getValue: function(_60a) {
                return $(_60a).val();
            },
            setValue: function(_60b, _60c) {
                $(_60b).val(_60c);
            },
            resize: function(_60d, _60e) {
                $(_60d)._outerWidth(_60e)._outerHeight(22);
            }
        },
        datebox: {
            init: function(_60f, _610) {
                var _611 = $("<input type=\"text\">").appendTo(_60f);
                _611.datebox(_610);
                return _611;
            },
            destroy: function(_612) {
                $(_612).datebox("destroy");
            },
            getValue: function(_613) {
                return $(_613).datebox("getValue");
            },
            setValue: function(_614, _615) {
                $(_614).datebox("setValue", _615);
            },
            resize: function(_616, _617) {
                $(_616).datebox("resize", _617);
            }
        },
        combobox: {
            init: function(_618, _619) {
                var _61a = $("<input type=\"text\">").appendTo(_618);
                _61a.combobox(_619 || {});
                return _61a;
            },
            destroy: function(_61b) {
                $(_61b).combobox("destroy");
            },
            getValue: function(_61c) {
                var opts = $(_61c).combobox("options");
                if (opts.multiple) {
                    return $(_61c).combobox("getValues").join(opts.separator);
                } else {
                    return $(_61c).combobox("getValue");
                }
            },
            setValue: function(_61d, _61e) {
                var opts = $(_61d).combobox("options");
                if (opts.multiple) {
                    if (_61e) {
                        $(_61d).combobox("setValues", _61e.split(opts.separator));
                    } else {
                        $(_61d).combobox("clear");
                    }
                } else {
                    $(_61d).combobox("setValue", _61e);
                }
            },
            resize: function(_61f, _620) {
                $(_61f).combobox("resize", _620);
            }
        },
        combotree: {
            init: function(_621, _622) {
                var _623 = $("<input type=\"text\">").appendTo(_621);
                _623.combotree(_622);
                return _623;
            },
            destroy: function(_624) {
                $(_624).combotree("destroy");
            },
            getValue: function(_625) {
                return $(_625).combotree("getValue");
            },
            setValue: function(_626, _627) {
                $(_626).combotree("setValue", _627);
            },
            resize: function(_628, _629) {
                $(_628).combotree("resize", _629);
            }
        }
    };
    $.fn.datagrid.methods = {
        options: function(jq) {
            var _62a = $.data(jq[0], "datagrid").options;
            var _62b = $.data(jq[0], "datagrid").panel.panel("options");
            var opts = $.extend(_62a, {
                width: _62b.width,
                height: _62b.height,
                closed: _62b.closed,
                collapsed: _62b.collapsed,
                minimized: _62b.minimized,
                maximized: _62b.maximized
            });
            return opts;
        },
        getPanel: function(jq) {
            return $.data(jq[0], "datagrid").panel;
        },
        getPager: function(jq) {
            return $.data(jq[0], "datagrid").panel.children("div.datagrid-pager");
        },
        getColumnFields: function(jq, _62c) {
            return _4f9(jq[0], _62c);
        },
        getColumnOption: function(jq, _62d) {
            return _4fa(jq[0], _62d);
        },
        resize: function(jq, _62e) {
            return jq.each(function() {
                _4b6(this, _62e);
            });
        },
        load: function(jq, _62f) {
            return jq.each(function() {
                var opts = $(this).datagrid("options");
                opts.pageNumber = 1;
                var _630 = $(this).datagrid("getPager");
                _630.pagination("refresh", {
                    pageNumber: 1
                });
                _5d7(this, _62f);
            });
        },
        reload: function(jq, _631) {
            return jq.each(function() {
                _5d7(this, _631);
            });
        },
        reloadFooter: function(jq, _632) {
            return jq.each(function() {
                var opts = $.data(this, "datagrid").options;
                var dc = $.data(this, "datagrid").dc;
                if (_632) {
                    $.data(this, "datagrid").footer = _632;
                }
                if (opts.showFooter) {
                    opts.view.renderFooter.call(opts.view, this, dc.footer2, false);
                    opts.view.renderFooter.call(opts.view, this, dc.footer1, true);
                    if (opts.view.onAfterRender) {
                        opts.view.onAfterRender.call(opts.view, this);
                    }
                    $(this).datagrid("fixRowHeight");
                }
            });
        },
        loading: function(jq) {
            return jq.each(function() {
                var opts = $.data(this, "datagrid").options;
                $(this).datagrid("getPager").pagination("loading");
                if (opts.loadMsg) {
                    var _633 = $(this).datagrid("getPanel");
                    if (!_633.children("div.datagrid-mask").length) {
                        $("<div class=\"datagrid-mask\" style=\"display:block\"></div>").appendTo(_633);
                        var msg = $("<div class=\"datagrid-mask-msg\" style=\"display:block;left:50%\"></div>").html(opts.loadMsg).appendTo(_633);
                        msg.css("marginLeft", -msg.outerWidth() / 2);
                    }
                }
            });
        },
        loaded: function(jq) {
            return jq.each(function() {
                $(this).datagrid("getPager").pagination("loaded");
                var _634 = $(this).datagrid("getPanel");
                _634.children("div.datagrid-mask-msg").remove();
                _634.children("div.datagrid-mask").remove();
            });
        },
        fitColumns: function(jq) {
            return jq.each(function() {
                _513(this);
            });
        },
        fixColumnSize: function(jq, _635) {
            return jq.each(function() {
                _4e3(this, _635);
            });
        },
        fixRowHeight: function(jq, _636) {
            return jq.each(function() {
                _4c7(this, _636);
            });
        },
        freezeRow: function(jq, _637) {
            return jq.each(function() {
                _4d4(this, _637);
            });
        },
        autoSizeColumn: function(jq, _638) {
            return jq.each(function() {
                _51f(this, _638);
            });
        },
        loadData: function(jq, data) {
            return jq.each(function() {
                _53f(this, data);
                _5c3(this);
            });
        },
        getData: function(jq) {
            return $.data(jq[0], "datagrid").data;
        },
        getRows: function(jq) {
            return $.data(jq[0], "datagrid").data.rows;
        },
        getFooterRows: function(jq) {
            return $.data(jq[0], "datagrid").footer;
        },
        getRowIndex: function(jq, id) {
            return _549(jq[0], id);
        },
        getChecked: function(jq) {
            return _550(jq[0]);
        },
        getSelected: function(jq) {
            var rows = _54c(jq[0]);
            return rows.length > 0 ? rows[0] : null;
        },
        getSelections: function(jq) {
            return _54c(jq[0]);
        },
        clearSelections: function(jq) {
            return jq.each(function() {
                var _639 = $.data(this, "datagrid").selectedRows;
                _639.splice(0, _639.length);
                _564(this);
            });
        },
        clearChecked: function(jq) {
            return jq.each(function() {
                var _63a = $.data(this, "datagrid").checkedRows;
                _63a.splice(0, _63a.length);
                _578(this);
            });
        },
        scrollTo: function(jq, _63b) {
            return jq.each(function() {
                _553(this, _63b);
            });
        },
        highlightRow: function(jq, _63c) {
            return jq.each(function() {
                _55a(this, _63c);
                _553(this, _63c);
            });
        },
        selectAll: function(jq) {
            return jq.each(function() {
                _56d(this);
            });
        },
        unselectAll: function(jq) {
            return jq.each(function() {
                _564(this);
            });
        },
        selectRow: function(jq, _63d) {
            return jq.each(function() {
                _55e(this, _63d);
            });
        },
        selectRecord: function(jq, id) {
            return jq.each(function() {
                var opts = $.data(this, "datagrid").options;
                if (opts.idField) {
                    var _63e = _549(this, id);
                    if (_63e >= 0) {
                        $(this).datagrid("selectRow", _63e);
                    }
                }
            });
        },
        unselectRow: function(jq, _63f) {
            return jq.each(function() {
                _566(this, _63f);
            });
        },
        checkRow: function(jq, _640) {
            return jq.each(function() {
                _565(this, _640);
            });
        },
        uncheckRow: function(jq, _641) {
            return jq.each(function() {
                _56c(this, _641);
            });
        },
        checkAll: function(jq) {
            return jq.each(function() {
                _572(this);
            });
        },
        uncheckAll: function(jq) {
            return jq.each(function() {
                _578(this);
            });
        },
        beginEdit: function(jq, _642) {
            return jq.each(function() {
                _58a(this, _642);
            });
        },
        endEdit: function(jq, _643) {
            return jq.each(function() {
                _590(this, _643, false);
            });
        },
        cancelEdit: function(jq, _644) {
            return jq.each(function() {
                _590(this, _644, true);
            });
        },
        getEditors: function(jq, _645) {
            return _59b(jq[0], _645);
        },
        getEditor: function(jq, _646) {
            return _59f(jq[0], _646);
        },
        refreshRow: function(jq, _647) {
            return jq.each(function() {
                var opts = $.data(this, "datagrid").options;
                opts.view.refreshRow.call(opts.view, this, _647);
            });
        },
        validateRow: function(jq, _648) {
            return _58f(jq[0], _648);
        },
        updateRow: function(jq, _649) {
            return jq.each(function() {
                var opts = $.data(this, "datagrid").options;
                opts.view.updateRow.call(opts.view, this, _649.index, _649.row);
            });
        },
        appendRow: function(jq, row) {
            return jq.each(function() {
                _5c0(this, row);
            });
        },
        insertRow: function(jq, _64a) {
            return jq.each(function() {
                _5bc(this, _64a);
            });
        },
        deleteRow: function(jq, _64b) {
            return jq.each(function() {
                _5b6(this, _64b);
            });
        },
        getChanges: function(jq, _64c) {
            return _5b0(jq[0], _64c);
        },
        acceptChanges: function(jq) {
            return jq.each(function() {
                _5c7(this);
            });
        },
        rejectChanges: function(jq) {
            return jq.each(function() {
                _5c9(this);
            });
        },
        mergeCells: function(jq, _64d) {
            return jq.each(function() {
                _5dd(this, _64d);
            });
        },
        showColumn: function(jq, _64e) {
            return jq.each(function() {
                var _64f = $(this).datagrid("getPanel");
                _64f.find("td[field=\"" + _64e + "\"]").show();
                $(this).datagrid("getColumnOption", _64e).hidden = false;
                $(this).datagrid("fitColumns");
            });
        },
        hideColumn: function(jq, _650) {
            return jq.each(function() {
                var _651 = $(this).datagrid("getPanel");
                _651.find("td[field=\"" + _650 + "\"]").hide();
                $(this).datagrid("getColumnOption", _650).hidden = true;
                $(this).datagrid("fitColumns");
            });
        }
    };
    $.fn.datagrid.parseOptions = function(obj) {
        var t = $(obj);
        return $.extend({},
        $.fn.panel.parseOptions(obj), $.parser.parseOptions(obj, ["url", "toolbar", "idField", "sortName", "sortOrder", "pagePosition", "resizeHandle", {
            fitColumns: "boolean",
            autoRowHeight: "boolean",
            striped: "boolean",
            nowrap: "boolean"
        },
        {
            rownumbers: "boolean",
            singleSelect: "boolean",
            checkOnSelect: "boolean",
            selectOnCheck: "boolean"
        },
        {
            pagination: "boolean",
            pageSize: "number",
            pageNumber: "number"
        },
        {
            multiSort: "boolean",
            remoteSort: "boolean",
            showHeader: "boolean",
            showFooter: "boolean"
        },
        {
            scrollbarSize: "number"
        }]), {
            pageList: (t.attr("pageList") ? eval(t.attr("pageList")) : undefined),
            loadMsg: (t.attr("loadMsg") != undefined ? t.attr("loadMsg") : undefined),
            rowStyler: (t.attr("rowStyler") ? eval(t.attr("rowStyler")) : undefined)
        });
    };
    $.fn.datagrid.parseData = function(obj) {
        var t = $(obj);
        var data = {
            total: 0,
            rows: []
        };
        var _654 = t.datagrid("getColumnFields", true).concat(t.datagrid("getColumnFields", false));
        t.find("tbody tr").each(function() {
            data.total++;
            var row = {};
            $.extend(row, $.parser.parseOptions(this, ["iconCls", "state"]));
            for (var i = 0; i < _654.length; i++) {
                row[_654[i]] = $(this).find("td:eq(" + i + ")").html();
            }
            data.rows.push(row);
        });
        return data;
    };
    var _655 = {
        render: function(obj, _657, _658) {
            var datagrid = $.data(obj, "datagrid");
            var opts = datagrid.options;
            var rows = datagrid.data.rows;
            var _65a = $(obj).datagrid("getColumnFields", _658);
            if (_658) {
                if (! (opts.rownumbers || (opts.frozenColumns && opts.frozenColumns.length))) {
                    return;
                }
            }
            var _65b = ["<table class='datagrid-btable' cellspacing='0' cellpadding='0' border='0'><tbody>"];
            for (var i = 0; i < rows.length; i++) {
                var css = opts.rowStyler ? opts.rowStyler.call(obj, i, rows[i]) : "";
                var _65c = "";
                var _65d = "";
                if (typeof css == "string") {
                    _65d = css;
                } else {
                    if (css) {
                        _65c = css["class"] || "";
                        _65d = css["style"] || "";
                    }
                }
                var cls = "class=\"datagrid-row " + (i % 2 && opts.striped ? "datagrid-row-alt ": " ") + _65c + "\"";
                var _65e = _65d ? "style=\"" + _65d + "\"": "";
                var _65f = datagrid.rowIdPrefix + "-" + (_658 ? 1 : 2) + "-" + i;
                _65b.push("<tr id=\"" + _65f + "\" datagrid-row-index=\"" + i + "\" " + cls + " " + _65e + ">");
                _65b.push(this.renderRow.call(this, obj, _65a, _658, i, rows[i]));
                _65b.push("</tr>");
            }
            _65b.push("</tbody></table>");
            $(_657).html(_65b.join(""));
        },
        renderFooter: function(objs, _661, _662) {
            var options = $.data(objs, "datagrid").options;
            var rows = $.data(objs, "datagrid").footer || [];
            var _663 = $(objs).datagrid("getColumnFields", _662);
            var _664 = ["<table class=\"datagrid-ftable\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody>"];
            for (var i = 0; i < rows.length; i++) {
                _664.push("<tr class=\"datagrid-row\" datagrid-row-index=\"" + i + "\">");
                _664.push(this.renderRow.call(this, objs, _663, _662, i, rows[i]));
                _664.push("</tr>");
            }
            _664.push("</tbody></table>");
            $(_661).html(_664.join(""));
        },
        renderRow: function(_665, _666, _667, _668, _669) {
            var opts = $.data(_665, "datagrid").options;
            var cc = [];
            if (_667 && opts.rownumbers) {
                var _66a = _668 + 1;
                if (opts.pagination) {
                    _66a += (opts.pageNumber - 1) * opts.pageSize;
                }
                cc.push("<td class=\"datagrid-td-rownumber\"><div class=\"datagrid-cell-rownumber\">" + _66a + "</div></td>");
            }
            for (var i = 0; i < _666.length; i++) {
                var _66b = _666[i];
                var col = $(_665).datagrid("getColumnOption", _66b);
                if (col) {
                    var _66c = _669[_66b];
                    var css = col.styler ? (col.styler(_66c, _669, _668) || "") : "";
                    var _66d = "";
                    var _66e = "";
                    if (typeof css == "string") {
                        _66e = css;
                    } else {
                        if (cc) {
                            _66d = css["class"] || "";
                            _66e = css["style"] || "";
                        }
                    }
                    var cls = _66d ? "class=\"" + _66d + "\"": "";
                    var _66f = col.hidden ? "style=\"display:none;" + _66e + "\"": (_66e ? "style=\"" + _66e + "\"": "");
                    cc.push("<td field=\"" + _66b + "\" " + cls + " " + _66f + ">");
                    if (col.checkbox) {
                        var _66f = "";
                    } else {
                        var _66f = _66e;
                        if (col.align) {
                            _66f += ";text-align:" + col.align + ";";
                        }
                        if (!opts.nowrap) {
                            _66f += ";white-space:normal;height:auto;";
                        } else {
                            if (opts.autoRowHeight) {
                                _66f += ";height:auto;";
                            }
                        }
                    }
                    cc.push("<div style=\"" + _66f + "\" ");
                    cc.push(col.checkbox ? "class=\"datagrid-cell-check\"": "class=\"datagrid-cell " + col.cellClass + "\"");
                    cc.push(">");
                    if (col.checkbox) {
                        cc.push("<input type=\"checkbox\" name=\"" + _66b + "\" value=\"" + (_66c != undefined ? _66c: "") + "\">");
                    } else {
                        if (col.formatter) {
                            cc.push(col.formatter(_66c, _669, _668));
                        } else {
                            cc.push(_66c);
                        }
                    }
                    cc.push("</div>");
                    cc.push("</td>");
                }
            }
            return cc.join("");
        },
        refreshRow: function(_670, _671) {
            this.updateRow.call(this, _670, _671, {});
        },
        updateRow: function(objs, _673, row) {
            var options = $.data(objs, "datagrid").options;
            var rows = $(objs).datagrid("getRows");
            $.extend(rows[_673], row);
            var css = options.rowStyler ? options.rowStyler.call(objs, _673, rows[_673]) : "";
            var _674 = "";
            var _675 = "";
            if (typeof css == "string") {
                _675 = css;
            } else {
                if (css) {
                    _674 = css["class"] || "";
                    _675 = css["style"] || "";
                }
            }
            var _674 = "datagrid-row " + (_673 % 2 && options.striped ? "datagrid-row-alt ": " ") + _674;
            function _676(_677) {
                var _678 = $(objs).datagrid("getColumnFields", _677);
                var tr = options.finder.getTr(objs, _673, "body", (_677 ? 1 : 2));
                var _679 = tr.find("div.datagrid-cell-check input[type=checkbox]").is(":checked");
                tr.html(this.renderRow.call(this, objs, _678, _677, _673, rows[_673]));
                tr.attr("style", _675).attr("class", _674);
                if (_679) {
                    tr.find("div.datagrid-cell-check input[type=checkbox]")._propAttr("checked", true);
                }
            };
            _676.call(this, true);
            _676.call(this, false);
            $(objs).datagrid("fixRowHeight", _673);
        },
        insertRow: function(obj, len, row) {
            var datagrid = $.data(obj, "datagrid");
            var options = datagrid.options;
            var dc = datagrid.dc;
            var data = datagrid.data;
            if (len == undefined || len == null) {
                len = data.rows.length;
            }
            if (len > data.rows.length) {
                len = data.rows.length;
            }
            function _67d(_67e) {
                var _67f = _67e ? 1 : 2;
                for (var i = data.rows.length - 1; i >= len; i--) {
                    var tr = options.finder.getTr(obj, i, "body", _67f);
                    tr.attr("datagrid-row-index", i + 1);
                    tr.attr("id", datagrid.rowIdPrefix + "-" + _67f + "-" + (i + 1));
                    if (_67e && options.rownumbers) {
                        var _680 = i + 2;
                        if (options.pagination) {
                            _680 += (options.pageNumber - 1) * options.pageSize;
                        }
                        tr.find("div.datagrid-cell-rownumber").html(_680);
                    }
                    if (options.striped) {
                        tr.removeClass("datagrid-row-alt").addClass((i + 1) % 2 ? "datagrid-row-alt": "");
                    }
                }
            };
            function _681(_682) {
                var _683 = _682 ? 1 : 2;
                var _684 = $(obj).datagrid("getColumnFields", _682);
                var _685 = datagrid.rowIdPrefix + "-" + _683 + "-" + len;
                var tr = "<tr id=\"" + _685 + "\" class=\"datagrid-row\" datagrid-row-index=\"" + len + "\"></tr>";
                if (len >= data.rows.length) {
                    if (data.rows.length) {
                        options.finder.getTr(obj, "", "last", _683).after(tr);
                    } else {
                        var cc = _682 ? dc.body1: dc.body2;
                        cc.html("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody>" + tr + "</tbody></table>");
                    }
                } else {
                    options.finder.getTr(obj, len + 1, "body", _683).before(tr);
                }
            };
            _67d.call(this, true);
            _67d.call(this, false);
            _681.call(this, true);
            _681.call(this, false);
            data.total += 1;
            data.rows.splice(len, 0, row);
            this.refreshRow.call(this, obj, len);
        },
        deleteRow: function(obj, _687) {
            var datagrid = $.data(obj, "datagrid");
            var options = datagrid.options;
            var data = datagrid.data;
            function _689(_68a) {
                var _68b = _68a ? 1 : 2;
                for (var i = _687 + 1; i < data.rows.length; i++) {
                    var tr = options.finder.getTr(obj, i, "body", _68b);
                    tr.attr("datagrid-row-index", i - 1);
                    tr.attr("id", datagrid.rowIdPrefix + "-" + _68b + "-" + (i - 1));
                    if (_68a && options.rownumbers) {
                        var _68c = i;
                        if (options.pagination) {
                            _68c += (options.pageNumber - 1) * options.pageSize;
                        }
                        tr.find("div.datagrid-cell-rownumber").html(_68c);
                    }
                    if (options.striped) {
                        tr.removeClass("datagrid-row-alt").addClass((i - 1) % 2 ? "datagrid-row-alt": "");
                    }
                }
            };
            options.finder.getTr(obj, _687).remove();
            _689.call(this, true);
            _689.call(this, false);
            data.total -= 1;
            data.rows.splice(_687, 1);
        },
        onBeforeRender: function(obj, rows) {},
        onAfterRender: function(obj) {
            var options = $.data(obj, "datagrid").options;
            if (options.showFooter) {
                var dgFooter = $(obj).datagrid("getPanel").find("div.datagrid-footer");
                dgFooter.find("div.datagrid-cell-rownumber,div.datagrid-cell-check").css("visibility", "hidden");
            }
        }
    };
    $.fn.datagrid.defaults = $.extend({},
    	$.fn.panel.defaults, 
    	{
	        frozenColumns: undefined,
	        columns: undefined,
	        fitColumns: false,
	        resizeHandle: "right",
	        autoRowHeight: true,
	        toolbar: null,
	        striped: false,
	        method: "post",
	        nowrap: true,
	        idField: null,
	        url: null,
	        data: null,
	        loadMsg: "Processing, please wait ...",
	        rownumbers: false,
	        singleSelect: false,
	        selectOnCheck: true,
	        checkOnSelect: true,
	        pagination: false,
	        pagePosition: "bottom",
	        pageNumber: 1,
	        pageSize: 10,
	        pageList: [10, 20, 30, 40, 50],
	        queryParams: {},
	        sortName: null,
	        sortOrder: "asc",
	        multiSort: false,
	        remoteSort: true,
	        showHeader: true,
	        showFooter: false,
	        scrollbarSize: 18,
	        rowStyler: function(_690, _691) {},
	        loader: function(_692, _693, _694) {
	            var opts = $(this).datagrid("options");
	            if (!opts.url) {
	                return false;
	            }
	            $.ajax({
	                type: opts.method,
	                url: opts.url,
	                data: _692,
	                dataType: "json",
	                success: function(data) {
	                    _693(data);
	                },
	                error: function() {
	                    _694.apply(this, arguments);
	                }
	            });
	        },
	        loadFilter: function(data) {
	            if (typeof data.length == "number" && typeof data.splice == "function") {
	                return {
	                    total: data.length,
	                    rows: data
	                };
	            } else {
	                return data;
	            }
	        },
	        editors: _5e5,
	        finder: {
	            getTr: function(_695, _696, type, _697) {
	                type = type || "body";
	                _697 = _697 || 0;
	                var _698 = $.data(_695, "datagrid");
	                var dc = _698.dc;
	                var opts = _698.options;
	                if (_697 == 0) {
	                    var tr1 = opts.finder.getTr(_695, _696, type, 1);
	                    var tr2 = opts.finder.getTr(_695, _696, type, 2);
	                    return tr1.add(tr2);
	                } else {
	                    if (type == "body") {
	                        var tr = $("#" + _698.rowIdPrefix + "-" + _697 + "-" + _696);
	                        if (!tr.length) {
	                            tr = (_697 == 1 ? dc.body1: dc.body2).find(">table>tbody>tr[datagrid-row-index=" + _696 + "]");
	                        }
	                        return tr;
	                    } else {
	                        if (type == "footer") {
	                            return (_697 == 1 ? dc.footer1: dc.footer2).find(">table>tbody>tr[datagrid-row-index=" + _696 + "]");
	                        } else {
	                            if (type == "selected") {
	                                return (_697 == 1 ? dc.body1: dc.body2).find(">table>tbody>tr.datagrid-row-selected");
	                            } else {
	                                if (type == "highlight") {
	                                    return (_697 == 1 ? dc.body1: dc.body2).find(">table>tbody>tr.datagrid-row-over");
	                                } else {
	                                    if (type == "checked") {
	                                        return (_697 == 1 ? dc.body1: dc.body2).find(">table>tbody>tr.datagrid-row:has(div.datagrid-cell-check input:checked)");
	                                    } else {
	                                        if (type == "last") {
	                                            return (_697 == 1 ? dc.body1: dc.body2).find(">table>tbody>tr[datagrid-row-index]:last");
	                                        } else {
	                                            if (type == "allbody") {
	                                                return (_697 == 1 ? dc.body1: dc.body2).find(">table>tbody>tr[datagrid-row-index]");
	                                            } else {
	                                                if (type == "allfooter") {
	                                                    return (_697 == 1 ? dc.footer1: dc.footer2).find(">table>tbody>tr[datagrid-row-index]");
	                                                }
	                                            }
	                                        }
	                                    }
	                                }
	                            }
	                        }
	                    }
	                }
	            },
	            getRow: function(_699, p) {
	                var _69a = (typeof p == "object") ? p.attr("datagrid-row-index") : p;
	                return $.data(_699, "datagrid").data.rows[parseInt(_69a)];
	            }
	        },
	        view: _655,
	        onBeforeLoad: function(_69b) {},
	        onLoadSuccess: function() {},
	        onLoadError: function() {},
	        onClickRow: function(_69c, _69d) {},
	        onDblClickRow: function(_69e, _69f) {},
	        onClickCell: function(_6a0, _6a1, _6a2) {},
	        onDblClickCell: function(_6a3, _6a4, _6a5) {},
	        onSortColumn: function(sort, _6a6) {},
	        onResizeColumn: function(_6a7, _6a8) {},
	        onSelect: function(_6a9, _6aa) {},
	        onUnselect: function(_6ab, _6ac) {},
	        onSelectAll: function(rows) {},
	        onUnselectAll: function(rows) {},
	        onCheck: function(_6ad, _6ae) {},
	        onUncheck: function(_6af, _6b0) {},
	        onCheckAll: function(rows) {},
	        onUncheckAll: function(rows) {},
	        onBeforeEdit: function(_6b1, _6b2) {},
	        onAfterEdit: function(_6b3, _6b4, _6b5) {},
	        onCancelEdit: function(_6b6, _6b7) {},
	        onHeaderContextMenu: function(e, _6b8) {},
	        onRowContextMenu: function(e, _6b9, _6ba) {}
    	}
    );
})(jQuery); 


